解密使用 MCRYPT_RIJNDAEL_128 加密的数据



CCAvenue 使用MCRYPT_RIJNDAEL_128来加密交易数据。由于我的服务器运行的是 PHP 7.1,因此我无法解密此数据。

是否有任何解决方法可以在 PHP 7.1 上解密此字符串,或者我是否必须降级到 PHP 5 才能使其正常工作。

来自ccavenue的解密代码

function decrypt($encryptedText,$key)
{
$secretKey = hextobin(md5($key));
$initVector = pack("C*", 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
$encryptedText=hextobin($encryptedText);
$openMode = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '','cbc', '');
mcrypt_generic_init($openMode, $secretKey, $initVector);
$decryptedText = mdecrypt_generic($openMode, $encryptedText);
$decryptedText = rtrim($decryptedText, "");
mcrypt_generic_deinit($openMode);
return $decryptedText;
}

解密响应

Call to undefined function mcrypt_module_open()

好的,我们的CCAvenue已经推出了与PHP 7.1兼容的版本。

开放 SSL 兼容版本的代码

function encrypt($plainText,$key)
{
$key = hextobin(md5($key));
$initVector = pack("C*", 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
$openMode = openssl_encrypt($plainText, 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $initVector);
$encryptedText = bin2hex($openMode);
return $encryptedText;
}
function decrypt($encryptedText,$key)
{
$key = hextobin(md5($key));
$initVector = pack("C*", 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
$encryptedText = hextobin($encryptedText);
$decryptedText = openssl_decrypt($encryptedText, 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $initVector);
return $decryptedText;
}

尝试使用 openssl_encrypt($input, 'AES-128-CBC', "KEY", OPENSSL_RAW_DATA, $iv(;

最新更新