The problem is that there are some things that PHP mcrypt (and node createCipher()) extends backstage that you probably don't know about.
, createCipher() , MD5 . , , createCipheriv(), ( IV), , PHP mcrypt. ECB IVs , IV.
-, PHP mcrypt , .
, AES-128-ECB , 16 . , crypto :
var crypto = require('crypto');
function makePadded(str) {
var buf;
var len = str.length;
if (str.length % 16)
len = str.length + (16 - str.length % 16);
buf = new Buffer(len);
buf.fill(0);
buf.write(str, 0, str.length);
return buf;
}
var ip = makePadded('MY_IP');
var secret = makePadded('MY_KEY');
var cipher = crypto.createCipheriv("AES-128-ECB", secret, '');
var encrypted = cipher.update(ip, 'binary', 'hex');
encrypted += cipher.final('hex');
encrypted = encrypted.slice(0, 32);
console.log(encrypted);
, , , MCRYPT_RIJNDAEL_128 PHP 128, 192 256 . PHP, 0 < keylen <= 16 128- , 192- , 16 < keylen <= 24 256- , 24 < keylen <= 32. node , node " ", PHP.