Socket
Socket
Sign inDemoInstall

@stablelib/chacha

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stablelib/chacha

ChaCha stream cipher


Version published
Weekly downloads
321K
decreased by-3.18%
Maintainers
1
Weekly downloads
 
Created

What is @stablelib/chacha?

@stablelib/chacha is a JavaScript library that provides implementations of the ChaCha stream cipher and the Poly1305 message authentication code. It is part of the StableLib collection of cryptographic libraries, which are designed to be secure, fast, and easy to use.

What are @stablelib/chacha's main functionalities?

ChaCha20 Encryption

This feature allows you to encrypt data using the ChaCha20 stream cipher. The code sample demonstrates how to initialize the cipher with a key and nonce, and then encrypt a plaintext message.

const { ChaCha20 } = require('@stablelib/chacha');
const key = new Uint8Array(32); // 256-bit key
const nonce = new Uint8Array(12); // 96-bit nonce
const plaintext = new Uint8Array([1, 2, 3, 4, 5]);
const chacha = new ChaCha20(key, nonce);
const ciphertext = chacha.encrypt(plaintext);
console.log(ciphertext);

ChaCha20 Decryption

This feature allows you to decrypt data that was encrypted using the ChaCha20 stream cipher. The code sample demonstrates how to initialize the cipher with a key and nonce, and then decrypt a ciphertext message.

const { ChaCha20 } = require('@stablelib/chacha');
const key = new Uint8Array(32); // 256-bit key
const nonce = new Uint8Array(12); // 96-bit nonce
const ciphertext = new Uint8Array([/* encrypted data */]);
const chacha = new ChaCha20(key, nonce);
const decrypted = chacha.decrypt(ciphertext);
console.log(decrypted);

Poly1305 Authentication

This feature allows you to generate a Poly1305 message authentication code (MAC) for a given message. The code sample demonstrates how to initialize the Poly1305 instance with a key, update it with a message, and then generate the authentication tag.

const { Poly1305 } = require('@stablelib/chacha');
const key = new Uint8Array(32); // 256-bit key
const message = new Uint8Array([1, 2, 3, 4, 5]);
const poly1305 = new Poly1305(key);
const tag = poly1305.update(message).digest();
console.log(tag);

Other packages similar to @stablelib/chacha

FAQs

Package last updated on 07 May 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc