A snappy and lightweight (259B) utility to encrypt and decrypt values with salt.
npm install salteen> 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
```
$ npm install --save salteen
`js
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']
`
Returns a new
Function which will accept a value to be encrypted, using salt as the salting value.#### salt
Type:
StringThe salting value to be used – longer salts are more secure.
$3
return FunctionReturns a new
Function which will accept a value to be decrypted, using salt as the salting value.#### salt
Type:
StringThe 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)
``MIT © Luke Edwards