crypto-promise

Promise version of Node.js crypto module.


License
Unlicense
Install
npm install crypto-promise@2.1.0

Documentation

crypto-promise npm version

Promise version of Node.js crypto module.

Example

const crypto = require('crypto-promise')

const test = async () => {
  const hash = await crypto.hash('md5')('hello')
  hash.toString('hex') // 5d41402abc4b2a76b9719d911017c592

  const hmac = await crypto.hmac('sha1', 'secret')('hello')
  hmac.toString('hex') // 5112055c05f944f85755efc5cd8970e194e9f45b

  const cipher = await crypto.cipher('aes256', 'secret')('hello')
  cipher.toString('hex') // f824105d6cadf7776b130cd80fdfeabf

  const decipher = await crypto.decipher('aes256', 'secret')('f824105d6cadf7776b130cd80fdfeabf', 'hex')
  decipher.toString() // hello

  const rand = await crypto.randomBytes(16)
  rand.length // 16
}

test()