js-chacha8

1.1.0 • Public • Published

JS-ChaCha8

Pure JavaScript ChaCha8 stream cipher

Description

This repository is changed from thesimj/js-chacha20 and uses the same open source license as the original repository. ChaCha8 is not described here.

Install

npm install js-chacha8 --save

Usage

Encrypt message with key and nonce

import JSChaCha8 from "js-chacha8";

const key = Buffer.alloc(32); // 32 bytes key
const nonce = Buffer.alloc(12); // 12 bytes nonce
const message = Buffer.allloc(64); // some data as bytes array

// Encrypt //
const encrypt = new JSChaCha8(key, nonce).encrypt(message);

// now encrypt contains buffer of encrypted message

Decrypt encrypted message with key and nonce

import JSChaCha8 from "js-chacha8";

const key = Buffer.alloc(32); // 32 bytes key
const nonce = Buffer.alloc(12); // 12 bytes nonce
const message = Buffer.allloc(64); // some data as bytes array

// Encrypt //
const message = new JSChaCha8(key, nonce).decrypt(encrypt);

// now message contains bufffer of original message

That all. If something happens, Error will be thrown. More examples you can find in tests files.

Package Sidebar

Install

npm i js-chacha8

Weekly Downloads

0

Version

1.1.0

License

MIT

Unpacked Size

13.4 kB

Total Files

10

Last publish

Collaborators

  • project-hako