Created
April 20, 2018 02:21
-
-
Save bbstilson/fd8d81d758731f354a9d1223ef45b132 to your computer and use it in GitHub Desktop.
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, password) { | |
const initVect = crypto.randomBytes(16); | |
const key = getCipherKey(password); | |
const cipher = createCipheriv('aes256', key, initVect); | |
const cipherText = cipher.update(text).digest(); | |
return initVect + ciphertext; | |
} | |
encrypt('hello', 'mygr8password'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's helpful, thanks!