Encrypt and decrypt
$ npm i -S @xet/cipher
Simple usage
const {encrypt, decrypt} = require('@xet/cipher')
const msg = 'secrect message'
const encrypted = encrypt(msg)
// => JkE4Mu4CBw3uaG1b6/1KQ118k2zBzARN/vyyaXmXxRtf1cjMCjhltvsJVd2wGnd90mTowHvc1h8JqCT1VbJVNw==
const decrypted = decrypt(encryptedMsg)
// => secrect message
With options
const {encrypt, decrypt} = require('@xet/cipher')
const options = {
_algHmac: 'sha1',
_algCypher: 'aes-256-cbc',
_key: 'apenas um show',
_outputEncoding: 'hex',
_lenKey: 32,
_lenIV: 16,
_useHex: true
}
const msg = 'secrect message'
const encrypted = encrypt(msg, options)
// => aa4ec6cb1747a3b6ad161aeeba3ace7e16e11866c3eedea0c994329d250d275be3a43011ff9ac5fba62510cf60eafaeb3617507b
const decrypted = decrypt(encryptedMsg, options)
// => secrect message
MIT © Thiago Lagden