Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
byte-base64
Advanced tools
base64 utilities for TypeScript and JavaScript.
This library allows you to encode all the following data structures to a base64-encoded string and back:
All other known solutions and approaches provide only a limited support for these features. In particular, atob and btoa only support ASCII strings.
byte-base64 is available as npm package.
npm i byte-base64
Consumption:
import * as base64 from "byte-base64";
Functions:
bytesToBase64(bytes: number[] | Uint8Array): string
- Encodes a Uint8Array or JS array of bytes to a base64-encoded
string.base64ToBytes(str: string): Uint8Array
- Decodes a base64-encoded string to a Uint8Array of bytes. If str
is not a
valid base64-encoded string, throws new Error("Unable to parse base64 string.")
.base64encode(str: string, encoder: { encode: (str: string) => Uint8Array | number[] } = new TextEncoder())
-
Encodes a JS string to a base64-encoded string using the specified character encoding. The encoding defaults
to new TextEncoder()
which represents UTF-8 encoding.base64decode(str: string, decoder: { decode: (bytes: Uint8Array) => string } = new TextDecoder())
- Decodes
a base64-encoded string to a JS string using the specified character encoding. The encoding defaults
to new TextDecoder()
which represents UTF-8 encoding. If str
is not a valid base64-encoded string,
throws new Error("Unable to parse base64 string.")
.TextEncoder supports only UTF-8 encoding in the majority of browsers. For more encodings, consider using a polyfill.
Project license is MIT.
FAQs
base64 utilities for TypeScript and JavaScript
We found that byte-base64 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.