Skip to content

Instantly share code, notes, and snippets.

@bbstilson
Created April 20, 2018 02:21
Show Gist options
  • Save bbstilson/fd8d81d758731f354a9d1223ef45b132 to your computer and use it in GitHub Desktop.
Save bbstilson/fd8d81d758731f354a9d1223ef45b132 to your computer and use it in GitHub Desktop.
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');
@cullylarson
Copy link

That's helpful, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment