Skip to content

Instantly share code, notes, and snippets.

@mkamakura
Last active March 29, 2019 21:26
Show Gist options
  • Save mkamakura/a51b561705baf4076930cd2440d7db17 to your computer and use it in GitHub Desktop.
Save mkamakura/a51b561705baf4076930cd2440d7db17 to your computer and use it in GitHub Desktop.
a sample to encrypt with AES-128-CBC on NodeJS
function encrypt(text, key, iv) {
let cipher = crypto.createCipheriv('aes-128-cbc', key, iv)
let encrypted = cipher.update(text)
encrypted = Buffer.concat([encrypted, cipher.final()])
return encrypted.toString('base64')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment