I have following test.php script:
$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.";
}
I call this script as follows:
http://localhost:8087/test/test.php?guid=08201E62-DFA5-8A50-ACFC-A811871804CD&encryptedGuid=ED40y72BJvzXmN0Aj9eb85VdIJKu6LUYQuYSWMPOhIQcm5SIquZAhRMmhsC7ax2e
Test.php script should display "Guid and decrypted Guid are equals." but it never occurs. I tried to check encoding of strings and $guid is ASCII and $encryptedGuid is UTF-8. Can you please help me how to solve this problem? I tried to convert ASCII to UTF-8 but I wasn't successful because result of e.g. iconv function was again ASCII. I think convert ASCII to UTF-8 can be solution but I am not sure if it is always true that $_GET returns ASCII.
Thank you very much for your help.