npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aez

v1.0.1

Published

AEZ implementation for node

Downloads

2,111

Readme

AEZ implementation for node

Build Status Coverage Status Open Source Love

npm version Dependency Status devDependency Status

This is an implementation of the AEZ authenticated-encryption scheme in JavaScript for node.

The code is based upon Yawning's implementation in Go and the reference implementation in C.

I am by no means an expert in high performance JavaScript or the underlying cryptography. So this library might be really slow.

The current version passes all test vectors generated with this hacked version of aez. But the author does not give any guarantees that the algorithm is implemented correctly for every edge case!

How to install

NPM:

npm install --save aez

yarn:

yarn add aez

How to use

NOTE: Every parameter that is not a number should be of type Buffer (or array of Buffer).

const aez = require('aez');
const Buffer = require('safe-buffer').Buffer;

const key = Buffer.from('1311f8fc80a7ea28d78dd7723f09c44c1754cd35160ca8e7133ae3d7f636a19a', 'hex'); // sha256 of 'my-secret-key', but you should use a key derivation function like scrypt or PBKDF2!
const salt = Buffer.from('abba0110', 'hex'); // some random salt
const plaintext = Buffer.from('please encrypt me!', 'utf8');
const tau = 4;

const cipherText = aez.encrypt(key, null, [salt], tau, plaintext);
console.log('The encrypted string is: ' + cipherText.toString('hex'));

const decryptedText = aez.decrypt(key, null, [salt], tau, cipherText);
console.log('The decrypted string is: ' + decryptedText.toString());

API

aez.encrypt(key : Buffer, nonce : Buffer, additionalData : Buffer[], tau : Number, plaintext : Buffer) : Buffer

Encrypts a plaintext buffer with the given key, nonce and additionalData.

aez.decrypt(key : Buffer, nonce : Buffer, additionalData : Buffer[], tau : Number, ciphertext : Buffer) : Buffer

Decrypts a ciphertext buffer with the given key, nonce and additionalData.

If the key is incorrect, null is returned.

Performance

The code is not yet optimized for performance.

The following throughputs were achieved on an Intel Core i7-6500U running on linux/amd64:

$ node test/aez_benchmark.js
Message size: 1 bytes x 18,225 ops/sec ±2.01% (79 runs sampled) 60 us/op 16.3 kB/s
Message size: 32 bytes x 18,561 ops/sec ±1.88% (87 runs sampled) 58 us/op 540.6 kB/s
Message size: 512 bytes x 7,669 ops/sec ±1.46% (88 runs sampled) 139 us/op 3.5 MB/s
Message size: 1024 bytes x 4,804 ops/sec ±1.26% (89 runs sampled) 221 us/op 4.4 MB/s
Message size: 2048 bytes x 2,607 ops/sec ±3.51% (84 runs sampled) 406 us/op 4.8 MB/s
Message size: 16384 bytes x 413 ops/sec ±1.27% (87 runs sampled) 2558 us/op 6.1 MB/s
Message size: 32768 bytes x 215 ops/sec ±0.62% (83 runs sampled) 4910 us/op 6.4 MB/s
Message size: 65536 bytes x 109 ops/sec ±0.72% (79 runs sampled) 9642 us/op 6.5 MB/s
Message size: 1024768 bytes x 7.23 ops/sec ±0.82% (22 runs sampled) 140133 us/op 7.0 MB/s
Done in 49.59s.