Skip to content
master
Switch branches/tags
Go to file
Code
This branch is 14 commits ahead, 2 commits behind devi:master.

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

About

Chacha20 in Javascript

Resources

Releases

No releases published

Packages

No packages published