note 60378 added to function.mcrypt-generic
| From: | RyanThomas at osu1 dot php dot net | Date: | Thu, 05 Jan 2006 10:15:52 +0000 |
| Subject: | note 60378 added to function.mcrypt-generic | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-101244@lists.php.net to get a copy of this message | ||
If you wish to store encrypted data in a cookie variable on the browser you will encounter problems
when decrypting the data. This is because cookies will only store US-ASCII characters and your
encrypted data may contain non-US-ASCII characters.
The solution:
base64_encode your encrypted string before you store it in the cookie and base64_decode the string
stored in the cookie becore decrypting.
Example:
function setEncryptedCookie($cookieName, $data)
{
setcookie($cookieName, base64_encode($this->encrypt($data)), time()+$this->expire);
}
function getEncryptedCookie($cookieName)
{
return $this->decrypt(base64_decode($_COOKIE[$cookieName]));
}
----
Manual Page -- http://www.php.net/manual/en/function.mcrypt-generic.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+60378
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60378&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60378&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60378&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60378&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60378&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60378&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60378&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+60378&report=yes
Search -- http://master.php.net/manage/user-notes.php