Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Crypto = require('crypto');
- module.exports = {
- decryptedText : function (text) {
- // we compute the sha256 of the key
- var hash = Crypto.createHash("md5");
- hash.update('pptik2018', "utf8");
- var sha128key = hash.digest();
- var keyBuffer = new Buffer(sha128key);
- var cipherBuffer = new Buffer(text, 'hex');
- // always use createDecipheriv when the key is passed as raw bytes
- var aesDec = Crypto.createDecipheriv("aes-128-ecb", keyBuffer , '');
- var output = aesDec.update(cipherBuffer);
- return output + aesDec.final();
- },
- encryptedText : function (text) {
- var cipher = Crypto.createCipher('aes-128-ecb','pptik2018');
- var crypted = cipher.update(text.toString(),'utf-8','hex');
- crypted += cipher.final('hex')
- return crypted;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement