我有以下 test.php 脚本:
$AES_IV = "4epZqMl8BQukhip6WQjQHg==";
$AES_KEY = "zvKmer0cPiJdQQ1RPjQOCF/wURt+31UdingRoPj4+Yc=";
$guid = $_GET["guid"];
$encryptedGuid = urldecode($_GET["encryptedGuid"]);
$decryptedGuid = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, base64_decode($AES_KEY), base64_decode($encryptedGuid), MCRYPT_MODE_CBC, base64_decode($AES_IV));
echo "Guid is: ".$guid."</br>";
echo "Decrypted GUID is: ".$decryptedGuid."</br>";
if ($decryptedGuid === $guid)
{
echo "Guid and decrypted Guid are equals.";
}
else
{
echo "Guid and decrypted Guid are not equals.";
}
我称这个脚本如下:
http://localhost:8087/test/test.php?guid=08201E62-DFA5-8A50-ACFC-A811871804CD&encryptedGuid=ED40y72BJvzXmN0Aj9eb85VdIJKu6LUYQuYSWMPOhIQcm5SIquZAhRMmhsC7ax2e
Test.php 脚本应显示“Guid 和解密的 Guid 相等”。但它永远不会发生。我试图检查字符串的编码,$guid 是 ASCII,$encryptedGuid 是 UTF-8。你能帮我解决这个问题吗?我尝试将 ASCII 转换为 UTF-8,但没有成功,因为例如 iconv 函数的结果又是 ASCII。我认为将 ASCII 转换为 UTF-8 可以解决,但我不确定 $_GET 返回 ASCII 是否总是正确的。
非常感谢您的帮助。