Last active
September 5, 2019 18:55
-
-
Save jaketrent/bb1b289cb8df09a389a8 to your computer and use it in GitHub Desktop.
Symmetrical AES Encryption
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
var crypto = require('crypto') | |
var cipherKey = 'the key to unlock the cipher' | |
var pwd = 'my secret' | |
var cipher = crypto.createCipher('aes256', cipherKey) | |
cipher.update(pwd, 'utf8', 'base64') | |
var encrypted = cipher.final('base64') | |
console.log('encrypted') | |
console.log(encrypted) | |
var decipher = crypto.createDecipher('aes256', cipherKey) | |
decipher.update(encrypted, 'base64', 'utf8') | |
var decrypted = decipher.final('utf8') | |
console.log('decrypted') | |
console.log(decrypted) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment