Skip to content

Instantly share code, notes, and snippets.

@jaketrent
Last active September 5, 2019 18:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaketrent/bb1b289cb8df09a389a8 to your computer and use it in GitHub Desktop.
Save jaketrent/bb1b289cb8df09a389a8 to your computer and use it in GitHub Desktop.
Symmetrical AES Encryption
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