salteen
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

salteen Build Status

A snappy and lightweight (259B) utility to encrypt and decrypt values with salt.

Both encrypt and decrypt are factory functions that accept a salt key and return new functions to be called with the unique value(s) to handle. This allows you reuse instances across multiple values.

This module is available in three formats:

  • CommonJS: dist/salteen.js
  • ESModule: dist/salteen.mjs
  • UMD: dist/salteen.min.js

Install

$ npm install --save salteen

Usage

const { encrypt, decrypt } = require('salteen');
 
const MY_SALT = 'foobar'; // PS: the longer the better
 
const encoder = encrypt(MY_SALT);
const decoder = decrypt(MY_SALT);
 
['hello', 'world'].map(encoder);
//=> ['7f727b7b78', '6078657b73']
 
['7f727b7b78', '6078657b73'].map(decoder);
//=> ['hello', 'world']

API

encrypt(salt)

Returns: Function

Returns a new Function which will accept a value<String> to be encrypted, using salt as the salting value.

salt

Type: String

The salting value to be used – longer salts are more secure.

decrypt(salt)

return Function

Returns a new Function which will accept a value<String> to be decrypted, using salt as the salting value.

salt

Type: String

The salting value to be used – longer salts are more secure.

Benchmarks

Results below are with Node v11.11.0

encrypt  x 281,299 ops/sec ±0.66% (97 runs sampled)
decrypt  x 383,827 ops/sec ±1.81% (90 runs sampled)

License

MIT © Luke Edwards

Package Sidebar

Install

npm i salteen

Weekly Downloads

256

Version

1.0.0

License

MIT

Unpacked Size

5.6 kB

Total Files

7

Last publish

Collaborators

  • lukeed