node-mac-crypt

1.0.0 • Public • Published

node-mac-crypt

Simple NodeJS Crypt Package with Mac Sign.


Usage

const crypto = require('crypto');
const MacCrypt = require('node-mac-crypt');

const crypt = new MacCrypt({
    key: 'my_secret_password',
    iv: crypto.randomBytes(16)
});

// String:
const message = 'My Secret Message!';
console.log(`Original Message: '${message}'`);

const encrypted = crypt.encrypt(message);
console.log(`Encrypted Message: '${encrypted}'`);

const decrypted = crypt.decrypt(encrypted);
console.log(`Decrypted Message: '${decrypted}'`);

// JSON:
const json = {data: 'My Secret Data!'};
console.log(`Original JSON Data:`, json);

const json_encrypted = crypt.encrypt(json);
console.log(`Encrypted JSON Data: '${json_encrypted}'`);

const json_decrypted = crypt.decrypt(json_encrypted);
console.log(`Decrypted JSON Data:`, json_decrypted);

Options

  • key {base64 string|Buffer} -- secret key.
  • iv {base64 string|Buffer} -- cipher iv (16 bytes length).
  • cipher {string} -- cipher algorithm (default 'aes-256-cbc').
  • mac_size {integer} -- mac sign size (default 6).
  • mac_separator {string} -- mac sign separator (default '::').
  • key_length {integer} -- secret key length in bytes (default 32).
  • serialize {function} -- message serialize method (default JSON.stringify).
  • unserialize {function} -- message unserialize method (default JSON.parse).

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    0

Package Sidebar

Install

npm i node-mac-crypt

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

5.05 kB

Total Files

4

Last publish

Collaborators

  • mightydes