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.
@stablelib/bytes
Advanced tools
@stablelib/bytes is a utility library for working with byte arrays in JavaScript. It provides a variety of functions for manipulating and converting byte arrays, making it easier to handle binary data.
Concatenation
This feature allows you to concatenate multiple byte arrays into a single byte array.
const bytes = require('@stablelib/bytes');
const array1 = new Uint8Array([1, 2, 3]);
const array2 = new Uint8Array([4, 5, 6]);
const concatenated = bytes.concat(array1, array2);
console.log(concatenated); // Uint8Array [1, 2, 3, 4, 5, 6]
Equality Check
This feature allows you to check if two byte arrays are equal.
const bytes = require('@stablelib/bytes');
const array1 = new Uint8Array([1, 2, 3]);
const array2 = new Uint8Array([1, 2, 3]);
const isEqual = bytes.equal(array1, array2);
console.log(isEqual); // true
Subarray Extraction
This feature allows you to extract a subarray from a given byte array.
const bytes = require('@stablelib/bytes');
const array = new Uint8Array([1, 2, 3, 4, 5]);
const subarray = bytes.subarray(array, 1, 3);
console.log(subarray); // Uint8Array [2, 3]
Hex Encoding/Decoding
This feature allows you to encode a byte array to a hex string and decode a hex string back to a byte array.
const bytes = require('@stablelib/bytes');
const array = new Uint8Array([1, 2, 3]);
const hexString = bytes.toHex(array);
console.log(hexString); // '010203'
const decodedArray = bytes.fromHex(hexString);
console.log(decodedArray); // Uint8Array [1, 2, 3]
The 'buffer' module from Node.js provides a way of handling binary data directly in JavaScript. It offers similar functionalities such as concatenation, slicing, and encoding/decoding. However, it is more tightly integrated with Node.js and may not be as lightweight as @stablelib/bytes.
The 'typedarray' package provides polyfills for JavaScript typed arrays, which are used for handling binary data. While it offers basic functionalities for working with byte arrays, it does not provide as many utility functions as @stablelib/bytes.
The 'arraybuffer-utils' package provides utility functions for working with ArrayBuffers and TypedArrays. It offers functionalities like concatenation, slicing, and conversion between different types of arrays. It is similar to @stablelib/bytes but may have a different API and set of features.
FAQs
Byte utilities
The npm package @stablelib/bytes receives a total of 344,920 weekly downloads. As such, @stablelib/bytes popularity was classified as popular.
We found that @stablelib/bytes demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.