MCRYPT_RAND Menulis ulang di Node JS
var crypto = require('crypto');
var text = "Some super mega text I want encode";
var skey = "rcbTw667C7zxghZ5U3gwhQlp22t8c5Rq";
function encode(text, skey) {
var len = text.length;
var padSize = 16 - ((len + 16 - 1) % 16 + 1);
for (var i = 0; i < padSize; i++) {
text += '\0';
}
var cipher = crypto.createCipheriv('aes-256-ecb', skey, '');
cipher.setAutoPadding(false);
var encrypted = cipher.update(text, 'utf8', 'base64');
encrypted += cipher.final('base64');
return encrypted;
}
console.log(encode(text, skey));
Mayur Nagle