New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

js-chacha8

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-chacha8

Pure JavaScript ChaCha8 stream cipher

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

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.

Keywords

cryptography

FAQs

Package last updated on 16 Feb 2023

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