lol this is just getting silly. somehow i got it to work, now i can encrypt and decrypt the cookie but there is something very wrong.
i use a cookie to display a users name and it decrypts as the users name now. but i use alot of these type statements
(login is the name of the cookie)
http://domain.com/profile.php?username=$login (an example link)
if ($UserName == $login)
{
display this
}
else
{
display that
}
and although the username and login both echo out to the same thing nothing happens this just started when i changed a few pages over to mcrypt encryption. i was using base_64 before and everything was fine as long as i had the decryption code at the top of the page which i also have with the mcrypt pages.
COMPLETELY OUTTA MY DEPTH HERE LOL
Here Is the code i use to set the cookie
Code: Select all
<?php
$key = "keystring";
$msg = "$UserName";
$size = mcrypt_get_iv_size (MCRYPT_blowfish, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv ($size, MCRYPT_DEV_RANDOM);
setcookie ("login", mcrypt_ecb(MCRYPT_blowfish, $key, $msg, MCRYPT_ENCRYPT, $iv), time()+604800);
?>
and here is the code i am using to decrypt the cookie
Code: Select all
$key = "keystring"; // Provide the key for the encryption routine---- THIS MUST BE KEPT SECRET
$size = mcrypt_get_iv_size (MCRYPT_blowfish, MCRYPT_MODE_ECB);
$msg = "$login";
$iv = mcrypt_create_iv ($size, MCRYPT_DEV_RANDOM);
$unencrypted = mcrypt_ecb(MCRYPT_blowfish, $key, $msg, MCRYPT_DECRYPT, $iv);
$gofar = "$unencrypted";
$login = "$gofar";