Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@stablelib/chacha20poly1305
Advanced tools
@stablelib/chacha20poly1305 is a JavaScript implementation of the ChaCha20-Poly1305 authenticated encryption algorithm. It is part of the StableLib collection of cryptographic libraries, which are designed to be secure, fast, and easy to use.
Encryption
This code demonstrates how to encrypt a message using the ChaCha20-Poly1305 algorithm. A 32-byte key and a 12-byte nonce are used to encrypt the message 'Hello, world!'.
const { ChaCha20Poly1305 } = require('@stablelib/chacha20poly1305');
const key = new Uint8Array(32); // 32-byte key
const nonce = new Uint8Array(12); // 12-byte nonce
const message = new TextEncoder().encode('Hello, world!');
const aead = new ChaCha20Poly1305(key);
const encrypted = aead.seal(nonce, message);
console.log(encrypted);
Decryption
This code demonstrates how to decrypt a message using the ChaCha20-Poly1305 algorithm. The same 32-byte key and 12-byte nonce used for encryption are required to decrypt the message.
const { ChaCha20Poly1305 } = require('@stablelib/chacha20poly1305');
const key = new Uint8Array(32); // 32-byte key
const nonce = new Uint8Array(12); // 12-byte nonce
const encrypted = new Uint8Array([...]); // Encrypted message
const aead = new ChaCha20Poly1305(key);
const decrypted = aead.open(nonce, encrypted);
console.log(new TextDecoder().decode(decrypted));
Authenticated Encryption with Additional Data (AEAD)
This code demonstrates how to perform authenticated encryption with additional data (AEAD) using the ChaCha20-Poly1305 algorithm. The additional data is included in the authentication process but is not encrypted.
const { ChaCha20Poly1305 } = require('@stablelib/chacha20poly1305');
const key = new Uint8Array(32); // 32-byte key
const nonce = new Uint8Array(12); // 12-byte nonce
const message = new TextEncoder().encode('Hello, world!');
const additionalData = new TextEncoder().encode('Additional data');
const aead = new ChaCha20Poly1305(key);
const encrypted = aead.seal(nonce, message, additionalData);
console.log(encrypted);
TweetNaCl is a cryptographic library that provides a variety of cryptographic functions, including the ChaCha20-Poly1305 authenticated encryption algorithm. It is known for its simplicity and small size. Compared to @stablelib/chacha20poly1305, TweetNaCl offers a broader range of cryptographic primitives but may not be as optimized for performance.
Libsodium is a widely-used cryptographic library that provides a comprehensive set of cryptographic functions, including ChaCha20-Poly1305. It is known for its high performance and security. Compared to @stablelib/chacha20poly1305, Libsodium offers more features and is available in multiple languages, but it may be more complex to use.
Crypto-JS is a popular JavaScript library that provides a variety of cryptographic algorithms, including AES, SHA, and HMAC. While it does not natively support ChaCha20-Poly1305, it offers a wide range of other cryptographic functions. Compared to @stablelib/chacha20poly1305, Crypto-JS is more general-purpose but lacks specific support for ChaCha20-Poly1305.
FAQs
ChaCha20-Poly1305 AEAD (RFC 7539)
The npm package @stablelib/chacha20poly1305 receives a total of 58,491 weekly downloads. As such, @stablelib/chacha20poly1305 popularity was classified as popular.
We found that @stablelib/chacha20poly1305 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.