@iteam/encrypt

0.3.2 • Public • Published

encrypt

Some (hopefully) sensible defaults for encrypting in node

The data is serialized using msgpack5. This allows for any valid js structure to be encrypted/decrypted

Install

npm install --save @iteam/encrypt

Use

Super simple

const {encrypt, decrypt} = require('@iteam/encrypt').init('my super secret password')

const encrypted = encrypt('some text')  // returns a Buffer
const decrypted = decrypt(encrypted)    // returns 'some text'

With options

const {encrypt, decrypt} = require('@iteam/encrypt')
  .init({
    algorithm: 'aes-256-gcm',   // Default is 'aes-256-cbc',
    authTag: true,              // Only works with gcm
    encoding: 'base64',         // Default is null - ie Buffer
    iv: Buffer.alloc(16),       // Not recommended. Sets iv to zeros only. Other, not recommended value is false which removes iv all together
    password: 'some password'
  })

const encrypted = encrypt('some text')  // returns a base64 encoded string
const decrypted = decrypt(encrypted)    // returns 'some text'

/@iteam/encrypt/

    Package Sidebar

    Install

    npm i @iteam/encrypt

    Weekly Downloads

    2

    Version

    0.3.2

    License

    MIT

    Unpacked Size

    33.6 kB

    Total Files

    7

    Last publish

    Collaborators

    • mittistormen
    • momentiris
    • iteamadmin
    • hansrollman