Source for file cookie.php
Documentation is available at cookie.php
* dbscript for PHP 4 & 5 - restful crud framework
* @version 0.1.2 -- 19-Feb-2007
* @author Brian Hendrickson <brian@dbscript.net>
* @link http://dbscript.net/
* @copyright Copyright 2007 Brian Hendrickson
* @license http://www.opensource.org/licenses/mit-license.php MIT License
* An md5 encrypted cookie, which times out after $expiration seconds.
* After you authenticate a user, set a cookie to securely and
* transparently propagate the user's id.
* Set $cookie->key to a unique string before set() and validate().
* function set_cookie() {
* $cookie = new Cookie();
* $cookie->userid = "foobar";
* function check_cookie() {
* $cookie = new Cookie();
* if ($cookie->validate()) {
* print "cookie is good";
* print "cookie is not good";
* {@link http://dbscript.net/cookie}
* @author Brian Hendrickson <brian@dbscript.net>
* @todo support for clients with cookies-disabled
function md5_encrypt($plain_text, $password, $iv_len = 16){
if ($n % 16) $plain_text .= str_repeat("\0", 16 - ($n % 16));
$iv = substr($password ^ $enc_text, 0, 512);
$iv = substr($block . $iv, 0, 512) ^ $password;
function md5_decrypt($enc_text, $password, $iv_len = 16){
$iv = substr($password ^ substr($enc_text, 0, $iv_len), 0, 512);
$block = substr($enc_text, $i, 16);
$plain_text .= $block ^ pack('H*', md5($iv));
$iv = substr($block . $iv, 0, 512) ^ $password;
|