cvs: pear /Crypt Crypt_NumberID.php Crypt_Rc4.php NumberID.php Rc4.php package.xml

From: Date: Mon, 23 Jul 2001 10:23:59 +0000
Subject: cvs: pear /Crypt Crypt_NumberID.php Crypt_Rc4.php NumberID.php Rc4.php package.xml
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-334@lists.php.net to get a copy of this message
zyprexia Mon Jul 23 06:23:59 2001 EDT Added files: /pear/Crypt Crypt_NumberID.php Crypt_Rc4.php Removed files: /pear/Crypt NumberID.php Rc4.php Modified files: /pear/Crypt package.xml Log: Update package.xml to new file names renamed NumberID.php to Crypt_NumberID.php renamed Rc4.php to Crypt_Rc4.php Index: pear/Crypt/package.xml diff -u pear/Crypt/package.xml:1.1 pear/Crypt/package.xml:1.2 --- pear/Crypt/package.xml:1.1 Mon Jul 23 05:58:04 2001 +++ pear/Crypt/package.xml Mon Jul 23 06:23:59 2001 @@ -19,7 +19,7 @@ </Release> <FileList> <Dir>/</Dir> - <File>Rc4.php</File> - <File>NumberID.php</File> + <File>Crypt_Rc4.php</File> + <File>Crypt_NumberID.php</File> </FileList> </Package> Index: pear/Crypt/Crypt_NumberID.php +++ pear/Crypt/Crypt_NumberID.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ // +----------------------------------------------------------------------+ // | PHP version 4.0 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.0 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | http://www.php.net/license/2_02.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Authors: Dave Mertens <dmertens@zyprexia.com> | // +----------------------------------------------------------------------+ // // $Id: Crypt_NumberID.php,v 1.1 2001/07/23 10:23:59 zyprexia Exp $ class NumberID { /** * * This is not a real encryption class, but it can be usefull. * * Especialy for eshops it's handy that the user gets another order nr than * the normal used order ID. A regular customer can see if the store is successfull * just by looking at the orderid's. * * This class created an order number that can be used as a referal for the customer. Intern * you can still use the order ID. * * Ofcourse it's possible to make an number of any id. * * The numbers are unique as long ID is below 1000000. */ /** * translate an ID into a number * * @param long $ID - Identifier * @return string containing the number */ function toNumber($ID) { mt_srand(time()); $str = sprintf("%02d", date("m") * 9); $str .= sprintf("%02d", date("s")); $str .= right(sprintf("%04d", date("z") * mt_rand(0, 16)), 4); $str .= right(sprintf("%06d", $ID), 6); $newstr = $str[12] . $str[6] . $str[8] . $str[1] . $str[4] . $str[11] . $str[2]; $newstr .= $str[7] . $str[9] . $str[3] . $str[5] . $str[10] . $str[0] . $str[13]; return $newstr; } /** * translate an number into an ID * * @param string nr - number create by toNumber function * @return long ID - your original ID */ function toId($nr) { return $nr[2] . $nr[8] . $nr[11] . $nr[5] . $nr[0] . $nr[13]; } } // end of NumberID class ?> Index: pear/Crypt/Crypt_Rc4.php +++ pear/Crypt/Crypt_Rc4.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ // +----------------------------------------------------------------------+ // | PHP version 4.0 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.0 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | http://www.php.net/license/2_02.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Authors: Dave Mertens <dmertens@zyprexia.com> | // +----------------------------------------------------------------------+ // // $Id: Crypt_Rc4.php,v 1.1 2001/07/23 10:23:59 zyprexia Exp $ /***** RC4 stream cipher routines implementation in PHP4 based on code written by Damien Miller <djm@mindrot.org> crypt is used to encrypt AND decrypt the messages! Usage: $key = "pear"; $message = "PEAR rulez!"; $rc4 = new RC4; $rc4->key($key); echo "Original message: $message <br>\n"; $rc4->crypt($message); echo "Encrypted message: $message <br>\n"; $rc4->crypt($message); echo "Decrypted message: $message <br>\n"; *****/ /** * RC4 stream cipher routines implementation in PHP4 based on code written by * Damien Miller <djm@mindrot.org> * * @version 0.1 * @author Dave Mertens <dmertens@zyprexia.com> */ class RC4 { var $s= array(); var $i= 0; var $j= 0; /** * Class Constructor. * * @return bool always true; */ function RC4() { return true; } /** * Assign encryption key to class * * @param string key - Key which will be used for encryption * @return void */ function key(&$key) { $len= strlen($key); for ($this->i = 0; $this->i < 256; $this->i++) { $this->s[$this->i] = $this->i; } $this->j = 0; for ($this->i = 0; $this->i < 256; $this->i++) { $this->j = ($this->j + $this->s[$this->i] + ord($key[$this->i % $len])) % 256; $t = $this->s[$this->i]; $this->s[$this->i] = $this->s[$this->j]; $this->s[$this->j] = $t; } $this->i = $this->j = 0; } /** * Encrypt/decrypt function * * @param string paramstr - string that will encrypted * @return void */ function crypt(&$paramstr) { $len= strlen($paramstr); for ($c= 0; $c < $len; $c++) { $this->i = ($this->i + 1) % 256; $this->j = ($this->j + $this->s[$this->i]) % 256; $t = $this->s[$this->i]; $this->s[$this->i] = $this->s[$this->j]; $this->s[$this->j] = $t; $t = ($this->s[$this->i] + $this->s[$this->j]) % 256; $paramstr[$c] = chr(ord($paramstr[$c]) ^ $this->s[$t]); } } } //end of RC4 class ?>

« previous php.pear.cvs (#334) next »