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

encrypt-uint8array

v1.0.0

Published

Encrypt and decrypt an `Uint8Array` using another `Uint8Array` as password

Downloads

156

Readme

encrypt-uint8array Build Status

Encrypt and decrypt an Uint8Array using another Uint8Array as password

Highlights

  • Simple to use, hard to misuse
  • Does not reinvent the wheel (based on themis)
  • Written in TypeScript (you get autocomplete suggestions in your IDE!)

Install

$ npm install encrypt-uint8array

Usage

const {
	encryptUint8Array,
	decryptUint8Array,
	encodeString, // For convenience, but can be done with native TextEncoder
	decodeString  // For convenience, but can be done with native TextDecoder
} = require('encrypt-uint8array');

(async () => {
	const secret = encodeString('This is the secret');
	const password = encodeString('P4s$w0Rd!');
	const encrypted = await encryptUint8Array(secret, password);
	console.log(encrypted);
	//=> Uint8Array [ 0, 1, 1, 65, /* ... */, 103, 26 ]
	const decrypted = await decryptUint8Array(encrypted, password);
	console.log(decrypted);
	//=> Uint8Array [ 84, 104, 105, 115, /* ... */, 101, 116 ]
	console.log(decodeString(decrypted));
	//=> 'This is the secret'

	await decryptUint8Array(encrypted, encodeString('wrong password'));
	//=> DecryptionError: Unable to decrypt - password is incorrect or data is corrupted.
})();

API

encryptUint8Array(data, password)

Async function that encrypts data with password. Returns a new Uint8Array.

data

Type: Uint8Array

The data to be encrypted.

password

Type: Uint8Array

The Uint8Array to be used as password.

decryptUint8Array(encryptedData, password)

Async function that decrypts encryptedData with password. Returns a new Uint8Array.

If encryptedData is not valid or the password is incorrect, this function will throw a DecryptionError.

encryptedData

Type: Uint8Array

The data to be decrypted.

password

Type: Uint8Array

The Uint8Array to be used as password.

License

MIT © Pedro Augusto de Paula Barbosa