如何解密PHP中由Rijndael加密的文本

时间:2012-03-12 03:07:22

标签: php .net encryption

我们使用 .NET 通过以下过程加密文本:

RijndaelManaged rijndaelCipher = new RijndaelManaged();
rijndaelCipher.Mode = CipherMode.CBC;
rijndaelCipher.Padding = PaddingMode.PKCS7;
rijndaelCipher.KeySize = 128;
rijndaelCipher.BlockSize = 128;

我们的合作伙伴之一尝试使用 PHP 对其进行解密,但失败了。 你知道PHP有现成的库来帮助他们吗?

由于

1 个答案:

答案 0 :(得分:2)

$decode = trim(base64_decode($decrypt));
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND);
$decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $mc_key, $decode, MCRYPT_MODE_ECB, $iv);