Created
September 11, 2019 07:51
-
-
Save DeevD/474d3923eda1a2eee0266fe6ee94e352 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
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)) |
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
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