Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

chacha20

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chacha20

A pure JavaScript implementation of the ChaCha20 cipher

latest
Source
npmnpm
Version
0.1.4
Version published
Weekly downloads
193
-29.56%
Maintainers
1
Weekly downloads
 
Created
Source

Pure javascript implementation of ChaCha20 originally written by @devi supporting draft-irtf-cfrg-chacha20-poly1305-01.

Being packaged here as a simple node.js and browserify module.

Usage

var chacha20 = require("chacha20");

var key = new Buffer(32);
key.fill(0);
var nonce = new Buffer(8);
nonce.fill(0);

var plaintext = "testing";
// pass in buffers, returns a buffer
var ciphertext = chacha20.encrypt(key, nonce, new Buffer(plaintext));
console.log(ciphertext.toString("hex")); // prints "02dd93d9c99f5a"
console.log(chacha20.decrypt(key, nonce, ciphertext).toString()); // prints "testing"

Nonce Size

The handling of the nonce differs between the reference and IETF Draft, where the reference uses an 8-byte nonce and the draft uses a 12-byte one with the first 4 bytes being a sender unique identifier. Passing a difference nonce buffer size will choose either mode.

Keywords

chacha

FAQs

Package last updated on 20 Nov 2015

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