Skip to content

Instantly share code, notes, and snippets.

@DeevD
Created September 11, 2019 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DeevD/474d3923eda1a2eee0266fe6ee94e352 to your computer and use it in GitHub Desktop.
Save DeevD/474d3923eda1a2eee0266fe6ee94e352 to your computer and use it in GitHub Desktop.
const crypto = require('crypto');
var key = "1234567890123456";
var cipher = crypto.createCipher('aes-128-ecb',key)
var text = "hello world this is encrypted from node js"
var crypted = cipher.update(text,'utf-8','hex')
crypted += cipher.final('hex');
function decrypt(text){
var decipher = crypto.createDecipher('aes-128-ecb',key)
var dec = decipher.update(text,'hex','utf8')
dec += decipher.final('utf8');
return dec;
}
var encryptedString = "8c0dfb318900c736aea03ee34b85c16c39cc1a155f29b4aa16daffc89bf7207b03d9924d29ea9d909297b38b66921814";
console.log(crypted)
console.log('decrypt ' ,decrypt(encryptedString))
const crypto = require('crypto');
var key = "1234567890123456";
var cipher = crypto.createCipher('aes-128-ecb',key)
var text = "hello world this is encrypted from node js"
var crypted = cipher.update(text,'utf-8','hex')
crypted += cipher.final('hex');
function decrypt(text){
var decipher = crypto.createDecipher('aes-128-ecb',key)
var dec = decipher.update(text,'hex','utf8')
dec += decipher.final('utf8');
return dec;
}
var encryptedString = "8c0dfb318900c736aea03ee34b85c16c39cc1a155f29b4aa16daffc89bf7207b03d9924d29ea9d909297b38b66921814";
console.log(crypted)
console.log('decrypt ' ,decrypt(encryptedString))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment