我需要更改代码,因为Mcrypt在PHP 7.2上已弃用。不幸的是我检查了很多解决方案,但我的结果在Mcrypt和OpenSSL之间总是不同。
$encryption_key = "6721zO71bSAXIU3S4NBQeb1a";
$pure_string = $number.";".$port.';'.$address;
$size = mcrypt_get_block_size(MCRYPT_3DES, MCRYPT_MODE_ECB);
$pad = $size - (strlen($pure_string) % $size);
$pure_string=$pure_string . str_repeat(chr($pad), $pad);
$iv_size = mcrypt_get_iv_size(MCRYPT_3DES, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$encrypted_string = mcrypt_encrypt(MCRYPT_3DES, $encryption_key,utf8_encode($pure_string), MCRYPT_MODE_ECB, $iv);
$session['chip'] = base64_encode($encrypted_string);
echo $session['chip'];
$encrypted_openssl = openssl_encrypt(utf8_encode($pure_string), "DES-ECB", $encryption_key, OPENSSL_RAW_DATA | OPENSSL_NO_PADDING, $iv);
echo base64_encode($encrypted_openssl);
RESULT
的mcrypt:pEzu2yhC9iTX2mCaRr45NOvR2yfz1AR9
OPENSSL:eyJZ + sku1OBOeo9j8a8YdJaZiNtPEdRC
有人可以帮助我吗?
感谢。