Last active
March 29, 2019 21:26
-
-
Save mkamakura/a51b561705baf4076930cd2440d7db17 to your computer and use it in GitHub Desktop.
a sample to encrypt with AES-128-CBC on NodeJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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