/cipher

Encrypt and decrypt

Primary LanguageJavaScriptMIT LicenseMIT

Cipher

NPM version XO code style


Encrypt and decrypt

Install

$ npm i -S @xet/cipher

Usage

Simple usage

const {encrypt, decrypt} = require('@xet/cipher')

const msg = 'secrect message'
const encryptedMsg = encrypt(msg)
// => R6Sgvs8UdiPhPiHwyH+5REMEhK2NTsRT+tRjnhfAyN3skLc1vALrvQVk229rq3fHuopncGb+fiQSUfkuWc7W8A==

const r = decrypt(encryptedMsg)
// => secrect message

With options

const {encrypt, decrypt} = require('@xet/cipher')

const options = {
  _algHmac: 'sha1',
  _alg: 'aes-256-cbc',
  _size: 16,
  _sizeKey: 32,
  _key: 'apenas um show',
  _encoding: 'hex'
}
const msg = 'secrect message'
const encryptedMsg = encrypt(msg, options)
// => 03a37b7e5921f5322523dbc6632cf1beceb5db0ddd7edb26f90c7fbffb5b7d1987eaac68db4e21b9496ebc580ac73342bbc7cd1b

const r = decrypt(encryptedMsg, options)
// => secrect message

Team

Thiago Lagden

License

MIT © Thiago Lagden