cvs: pear /Text_Password Password.php package.xml /Text_Password/tests 01-text-password.phpt
| From: | Olivier Vanhoucke | Date: | Fri, 03 Jan 2003 12:34:07 +0000 |
| Subject: | cvs: pear /Text_Password Password.php package.xml /Text_Password/tests 01-text-password.phpt | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-8065@lists.php.net to get a copy of this message | ||
olivier Fri Jan 3 07:34:07 2003 EDT
Modified files:
/pear/Text_Password Password.php package.xml
/pear/Text_Password/tests 01-text-password.phpt
Log:
add new fonctions and rename functions
Index: pear/Text_Password/Password.php diff -u pear/Text_Password/Password.php:1.3 pear/Text_Password/Password.php:1.4 --- pear/Text_Password/Password.php:1.3 Mon Nov 11 05:53:53 2002 +++ pear/Text_Password/Password.php Fri Jan 3 07:34:07 2003 @@ -17,10 +17,13 @@ // | Olivier Vanhoucke <olivier@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Password.php,v 1.3 2002/11/11 10:53:53 olivier Exp $ +// $Id: Password.php,v 1.4 2003/01/03 12:34:07 olivier Exp $ // -$_Text_Password_nbrCharacters = 0; +/** + * Number of possible characters in the password + */ + $_Text_Password_NumberOfPossibleCharacters = 0; /** * Create passwords @@ -92,23 +95,41 @@ * @access public * @param string Login * @param string Type - * @param integer ? + * @param integer Key * @return string */ - function createFromLogin($login, $type, $cpt = 0) { + function createFromLogin($login, $type, $key = 0) { switch ($type) { case 'reverse': - return Text_Password::_reverseLogin($login); + return strrev($login); + + case 'shuffle': + return Text_Password::_shuffle($login); + + case 'xor': + return Text_Password::_xor($login, $key); + + case 'rot13': + return str_rot13($login); - case 'increment_char': - return Text_Password::_incrementLoginChar($login, $cpt); + case 'rotx': + return Text_Password::_rotx($login, $key); - case 'increment_char2': - return Text_Password::_incrementLoginChar2($login, $cpt); + case 'rotx++': + return Text_Password::_rotxpp($login, $key); - case 'increment_char3': - return Text_Password::_incrementLoginChar3($login, $cpt); + case 'rotx--': + return Text_Password::_rotxmm($login, $key); + + case 'ascii_rotx': + return Text_Password::_asciiRotx($login, $key); + + case 'ascii_rotx++': + return Text_Password::_asciiRotxpp($login, $key); + + case 'ascii_rotx--': + return Text_Password::_asciiRotxmm($login, $key); } } @@ -120,10 +141,10 @@ * @access public * @param array Login * @param string Type - * @param integer ? + * @param integer Key * @return array Array containing the passwords */ - function createMultipleFromLogin($login, $type, $cpt = 0) { + function createMultipleFromLogin($login, $type, $key = 0) { $passwords = array(); $number = count($login); @@ -131,7 +152,7 @@ while ($number > 0) { while (true) { - $password = Text_Password::createFromLogin($login[$save - $number], $type, $cpt); + $password = Text_Password::createFromLogin($login[$save - $number], $type, $key); if (!in_array($password, $passwords)) { $passwords[] = $password; break; @@ -145,56 +166,208 @@ /** * Create password from login * - * Method to create a password which is the reverse of the login + * Method to create a password from a login * * @access private * @param string Login + * @param integer Key * @return string */ - function _reverseLogin($login) { + function _xor($login, $key) { - for ($i=0; $i < strlen($login); $i++) { - $tmp[] = $login{$i}; + $tmp = ''; + + for ($i = 0; $i < strlen($login); $i++) { + $next = ord($login{$i}) ^ $key; + if ($next > 255) { + $next -= 255; + } elseif ($next < 0) { + $next += 255; + } + $tmp .= chr($next); } - return implode(array_reverse($tmp), ''); + return $tmp; } /** * Create password from login * * Method to create a password from a login + * lowercase only * * @access private * @param string Login + * @param integer Key * @return string */ - function _incrementLoginChar($login, $cpt) { + function _rotx($login, $key) { + + $tmp = ''; + $login = strtolower($login); - for ($i=0; $i < strlen($login); $i++) { - $tmp[] = chr(ord($login{$i}) + $cpt); + for ($i = 0; $i < strlen($login); $i++) { + if ((ord($login{$i}) >= 97) && (ord($login{$i}) <= 122)) { // 65, 90 for uppercase + $next = ord($login{$i}) + $key; + if ($next > 122) { + $next -= 26; + } elseif ($next < 97) { + $next += 26; + } + $tmp .= chr($next); + } else { + $tmp .= $login{$i}; + } } - return implode($tmp, ''); + return $tmp; } /** * Create password from login * * Method to create a password from a login + * lowercase only * * @access private * @param string Login + * @param integer Key * @return string */ - function _incrementLoginChar2($login, $cpt) { + function _rotxpp($login, $key) { + + $tmp = ''; + $login = strtolower($login); + + for ($i = 0; $i < strlen($login); $i++, $key++) { + if ((ord($login{$i}) >= 97) && (ord($login{$i}) <= 122)) { // 65, 90 for uppercase + $next = ord($login{$i}) + $key; + if ($next > 122) { + $next -= 26; + } elseif ($next < 97) { + $next += 26; + } + $tmp .= chr($next); + } else { + $tmp .= $login{$i}; + } + } + + return $tmp; + } - for ($i=0; $i < strlen($login); $i++) { - $tmp[] = chr(ord($login{$i}) + $cpt); - $cpt++; + /** + * Create password from login + * + * Method to create a password from a login + * lowercase only + * + * @access private + * @param string Login + * @param integer Key + * @return string + */ + function _rotxmm($login, $key) { + + $tmp = ''; + $login = strtolower($login); + + for ($i = 0; $i < strlen($login); $i++, $key--) { + if ((ord($login{$i}) >= 97) && (ord($login{$i}) <= 122)) { // 65, 90 for uppercase + $next = ord($login{$i}) + $key; + if ($next > 122) { + $next -= 26; + } elseif ($next < 97) { + $next += 26; + } + $tmp .= chr($next); + } else { + $tmp .= $login{$i}; + } } - return implode($tmp, ''); + return $tmp; + } + + /** + * Create password from login + * + * Method to create a password from a login + * + * @access private + * @param string Login + * @param integer Key + * @return string + */ + function _asciiRotx($login, $key) { + + $tmp = ''; + + for ($i = 0; $i < strlen($login); $i++) { + $next = ord($login{$i}) + $key; + if ($next > 255) { + $next -= 255; + } elseif ($next < 0) { + $next += 255; + } + $tmp .= chr($next); + } + + return $tmp; + } + + /** + * Create password from login + * + * Method to create a password from a login + * + * @access private + * @param string Login + * @param integer Key + * @return string + */ + function _asciiRotxpp($login, $key) { + + $tmp = ''; + + for ($i = 0; $i < strlen($login); $i++, $key++) { + $next = ord($login{$i}) + $key; + if ($next > 255) { + $next -= 255; + } elseif ($next < 0) { + $next += 255; + } + $tmp .= chr($next); + } + + return $tmp; + } + + /** + * Create password from login + * + * Method to create a password from a login + * + * @access private + * @param string Login + * @param integer Key + * @return string + */ + function _asciiRotxmm($login, $key) { + + $tmp = ''; + + for ($i = 0; $i < strlen($login); $i++, $key--) { + $next = ord($login{$i}) + $key; + if ($next > 255) { + $next -= 255; + } elseif ($next < 0) { + $next += 255; + } + $tmp .= chr($next); + } + + return $tmp; } /** @@ -206,9 +379,11 @@ * @param string Login * @return string */ - function _incrementLoginChar3($login, $cpt) { + function _shuffle($login) { + + $tmp = array(); - for ($i=0; $i < strlen($login); $i++) { + for ($i = 0; $i < strlen($login); $i++) { $tmp[] = $login{$i}; } @@ -229,7 +404,7 @@ */ function _createPronounceable($length) { - global $_Text_Password_nbrCharacters; + global $_Text_Password_NumberOfPossibleCharacters; $retVal = ''; @@ -249,13 +424,10 @@ 'ch', 'ph', 'st', 'sl', 'cl' ); - /** - * XXX: Make this static! - */ - $v_count = count($v); - $c_count = count($c); + $v_count = 12; + $c_count = 29; - $_Text_Password_nbrCharacters = $v_count + $c_count; + $_Text_Password_NumberOfPossibleCharacters = $v_count + $c_count; for ($i = 0; $i < $length; $i++) { $retVal .= $c[mt_rand(0, $c_count-1)] . $v[mt_rand(0, $v_count-1)]; @@ -274,9 +446,9 @@ * @param string Character which could be use in the password ex : 'A,B,C,D,E,F,G' or numeric or alphanumeric * @return string Returns the password */ - function _createUnpronounceable($length, $chars) { // en cours + function _createUnpronounceable($length, $chars) { - global $_Text_Password_nbrCharacters; + global $_Text_Password_NumberOfPossibleCharacters; $password = ''; @@ -287,17 +459,17 @@ case 'alphanumeric': $regex = 'A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|0|1|2|3|4|5|6|7|8|9'; - $_Text_Password_nbrCharacters = 62; + $_Text_Password_NumberOfPossibleCharacters = 62; break; case 'numeric': $regex = '0|1|2|3|4|5|6|7|8|9'; - $_Text_Password_nbrCharacters = 10; + $_Text_Password_NumberOfPossibleCharacters = 10; break; case '': $regex = '_|#|@|%|£|&|ç|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|0|1|2|3|4|5|6|7|8|9'; - $_Text_Password_nbrCharacters = 69; + $_Text_Password_NumberOfPossibleCharacters = 69; break; default: @@ -318,7 +490,7 @@ } $regex = str_replace(',', '|', $chars); - $_Text_Password_nbrCharacters = strlen(str_replace(',', '', $chars)); + $_Text_Password_NumberOfPossibleCharacters = strlen(str_replace(',', '', $chars)); } /** Index: pear/Text_Password/package.xml diff -u pear/Text_Password/package.xml:1.2 pear/Text_Password/package.xml:1.3 --- pear/Text_Password/package.xml:1.2 Mon Nov 11 05:53:53 2002 +++ pear/Text_Password/package.xml Fri Jan 3 07:34:07 2003 @@ -30,6 +30,7 @@ <file role="php" baseinstalldir="Text">Password.php</file> <dir name="tests"> <file role="test">01-text-password.phpt</file> + <file role="test">02-html-password.phpt</file> </dir> </filelist> </release> Index: pear/Text_Password/tests/01-text-password.phpt diff -u pear/Text_Password/tests/01-text-password.phpt:1.3 pear/Text_Password/tests/01-text-password.phpt:1.4 --- pear/Text_Password/tests/01-text-password.phpt:1.3 Mon Nov 11 05:53:53 2002 +++ pear/Text_Password/tests/01-text-password.phpt Fri Jan 3 07:34:07 2003 @@ -5,9 +5,9 @@ function timeToBruteForce ($password, $nbr = 0, $cmbPerSeconde = 4000) { - global $_Text_Password_nbrCharacters; + global $_Text_Password_NumberOfPossibleCharacters; - $nbr = ($nbr == 0) ? $_Text_Password_nbrCharacters : $nbr; + $nbr = ($nbr == 0) ? $_Text_Password_NumberOfPossibleCharacters : $nbr; $cmb = pow($nbr, strlen($password)); $time_max = $cmb / $cmbPerSeconde; $time_min = ($cmb / $cmbPerSeconde) / 2; @@ -42,14 +42,32 @@ echo "\nCreating password from login 'olivier', type is 'reverse':\t"; echo Text_Password::createFromLogin('olivier', 'reverse') . "\n\n"; -echo "\nCreating password from login 'olivier', type is 'increment_char':\t"; -echo Text_Password::createFromLogin('olivier', 'increment_char', 1) . "\n\n"; +echo "\nCreating password from login 'olivier', type is 'rot13':\t"; +echo Text_Password::createFromLogin('olivier', 'rot13') . "\n\n"; -echo "\nCreating password from login 'olivier', type is 'increment_char2':\t"; -echo Text_Password::createFromLogin('olivier', 'increment_char2', 1) . "\n\n"; +echo "\nCreating password from login 'olivier', type is 'rotx':\t"; +echo Text_Password::createFromLogin('olivier', 'rotx', 13) . "\n\n"; -echo "\nCreating password from login 'olivier', type is 'increment_char3':\t"; -echo Text_Password::createFromLogin('olivier', 'increment_char3', 1) . "\n\n"; +echo "\nCreating password from login 'olivier', type is 'rotx++':\t"; +echo Text_Password::createFromLogin('olivier', 'rotx++', 13) . "\n\n"; + +echo "\nCreating password from login 'olivier', type is 'rotx--':\t"; +echo Text_Password::createFromLogin('olivier', 'rotx--', 13) . "\n\n"; + +echo "\nCreating password from login 'olivier', type is 'xor':\t"; +echo Text_Password::createFromLogin('olivier', 'xor', 5) . "\n\n"; + +echo "\nCreating password from login 'olivier', type is 'ascii_rotx':\t"; +echo Text_Password::createFromLogin('olivier', 'ascii_rotx', 5) . "\n\n"; + +echo "\nCreating password from login 'olivier', type is 'ascii_rotx++':\t"; +echo Text_Password::createFromLogin('olivier', 'ascii_rotx++', 5) . "\n\n"; + +echo "\nCreating password from login 'olivier', type is 'ascii_rotx--':\t"; +echo Text_Password::createFromLogin('olivier', 'ascii_rotx--', 5) . "\n\n"; + +echo "\nCreating password from login 'olivier', type is 'shuffle':\t"; +echo Text_Password::createFromLogin('olivier', 'shuffle', 1) . "\n\n"; echo "\nCreating password from an array of login 'olivier', 'martin', 'vanhoucke', 'jansen', type is 'reverse':\n"; $logins = array('olivier', 'martin', 'vanhoucke', 'jansen');
Index: pear/Text_Password/Password.php diff -u pear/Text_Password/Password.php:1.3 pear/Text_Password/Password.php:1.4 --- pear/Text_Password/Password.php:1.3 Mon Nov 11 05:53:53 2002 +++ pear/Text_Password/Password.php Fri Jan 3 07:34:07 2003 @@ -17,10 +17,13 @@ // | Olivier Vanhoucke <olivier@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Password.php,v 1.3 2002/11/11 10:53:53 olivier Exp $ +// $Id: Password.php,v 1.4 2003/01/03 12:34:07 olivier Exp $ // -$_Text_Password_nbrCharacters = 0; +/** + * Number of possible characters in the password + */ + $_Text_Password_NumberOfPossibleCharacters = 0; /** * Create passwords @@ -92,23 +95,41 @@ * @access public * @param string Login * @param string Type - * @param integer ? + * @param integer Key * @return string */ - function createFromLogin($login, $type, $cpt = 0) { + function createFromLogin($login, $type, $key = 0) { switch ($type) { case 'reverse': - return Text_Password::_reverseLogin($login); + return strrev($login); + + case 'shuffle': + return Text_Password::_shuffle($login); + + case 'xor': + return Text_Password::_xor($login, $key); + + case 'rot13': + return str_rot13($login); - case 'increment_char': - return Text_Password::_incrementLoginChar($login, $cpt); + case 'rotx': + return Text_Password::_rotx($login, $key); - case 'increment_char2': - return Text_Password::_incrementLoginChar2($login, $cpt); + case 'rotx++': + return Text_Password::_rotxpp($login, $key); - case 'increment_char3': - return Text_Password::_incrementLoginChar3($login, $cpt); + case 'rotx--': + return Text_Password::_rotxmm($login, $key); + + case 'ascii_rotx': + return Text_Password::_asciiRotx($login, $key); + + case 'ascii_rotx++': + return Text_Password::_asciiRotxpp($login, $key); + + case 'ascii_rotx--': + return Text_Password::_asciiRotxmm($login, $key); } } @@ -120,10 +141,10 @@ * @access public * @param array Login * @param string Type - * @param integer ? + * @param integer Key * @return array Array containing the passwords */ - function createMultipleFromLogin($login, $type, $cpt = 0) { + function createMultipleFromLogin($login, $type, $key = 0) { $passwords = array(); $number = count($login); @@ -131,7 +152,7 @@ while ($number > 0) { while (true) { - $password = Text_Password::createFromLogin($login[$save - $number], $type, $cpt); + $password = Text_Password::createFromLogin($login[$save - $number], $type, $key); if (!in_array($password, $passwords)) { $passwords[] = $password; break; @@ -145,56 +166,208 @@ /** * Create password from login * - * Method to create a password which is the reverse of the login + * Method to create a password from a login * * @access private * @param string Login + * @param integer Key * @return string */ - function _reverseLogin($login) { + function _xor($login, $key) { - for ($i=0; $i < strlen($login); $i++) { - $tmp[] = $login{$i}; + $tmp = ''; + + for ($i = 0; $i < strlen($login); $i++) { + $next = ord($login{$i}) ^ $key; + if ($next > 255) { + $next -= 255; + } elseif ($next < 0) { + $next += 255; + } + $tmp .= chr($next); } - return implode(array_reverse($tmp), ''); + return $tmp; } /** * Create password from login * * Method to create a password from a login + * lowercase only * * @access private * @param string Login + * @param integer Key * @return string */ - function _incrementLoginChar($login, $cpt) { + function _rotx($login, $key) { + + $tmp = ''; + $login = strtolower($login); - for ($i=0; $i < strlen($login); $i++) { - $tmp[] = chr(ord($login{$i}) + $cpt); + for ($i = 0; $i < strlen($login); $i++) { + if ((ord($login{$i}) >= 97) && (ord($login{$i}) <= 122)) { // 65, 90 for uppercase + $next = ord($login{$i}) + $key; + if ($next > 122) { + $next -= 26; + } elseif ($next < 97) { + $next += 26; + } + $tmp .= chr($next); + } else { + $tmp .= $login{$i}; + } } - return implode($tmp, ''); + return $tmp; } /** * Create password from login * * Method to create a password from a login + * lowercase only * * @access private * @param string Login + * @param integer Key * @return string */ - function _incrementLoginChar2($login, $cpt) { + function _rotxpp($login, $key) { + + $tmp = ''; + $login = strtolower($login); + + for ($i = 0; $i < strlen($login); $i++, $key++) { + if ((ord($login{$i}) >= 97) && (ord($login{$i}) <= 122)) { // 65, 90 for uppercase + $next = ord($login{$i}) + $key; + if ($next > 122) { + $next -= 26; + } elseif ($next < 97) { + $next += 26; + } + $tmp .= chr($next); + } else { + $tmp .= $login{$i}; + } + } + + return $tmp; + } - for ($i=0; $i < strlen($login); $i++) { - $tmp[] = chr(ord($login{$i}) + $cpt); - $cpt++; + /** + * Create password from login + * + * Method to create a password from a login + * lowercase only + * + * @access private + * @param string Login + * @param integer Key + * @return string + */ + function _rotxmm($login, $key) { + + $tmp = ''; + $login = strtolower($login); + + for ($i = 0; $i < strlen($login); $i++, $key--) { + if ((ord($login{$i}) >= 97) && (ord($login{$i}) <= 122)) { // 65, 90 for uppercase + $next = ord($login{$i}) + $key; + if ($next > 122) { + $next -= 26; + } elseif ($next < 97) { + $next += 26; + } + $tmp .= chr($next); + } else { + $tmp .= $login{$i}; + } } - return implode($tmp, ''); + return $tmp; + } + + /** + * Create password from login + * + * Method to create a password from a login + * + * @access private + * @param string Login + * @param integer Key + * @return string + */ + function _asciiRotx($login, $key) { + + $tmp = ''; + + for ($i = 0; $i < strlen($login); $i++) { + $next = ord($login{$i}) + $key; + if ($next > 255) { + $next -= 255; + } elseif ($next < 0) { + $next += 255; + } + $tmp .= chr($next); + } + + return $tmp; + } + + /** + * Create password from login + * + * Method to create a password from a login + * + * @access private + * @param string Login + * @param integer Key + * @return string + */ + function _asciiRotxpp($login, $key) { + + $tmp = ''; + + for ($i = 0; $i < strlen($login); $i++, $key++) { + $next = ord($login{$i}) + $key; + if ($next > 255) { + $next -= 255; + } elseif ($next < 0) { + $next += 255; + } + $tmp .= chr($next); + } + + return $tmp; + } + + /** + * Create password from login + * + * Method to create a password from a login + * + * @access private + * @param string Login + * @param integer Key + * @return string + */ + function _asciiRotxmm($login, $key) { + + $tmp = ''; + + for ($i = 0; $i < strlen($login); $i++, $key--) { + $next = ord($login{$i}) + $key; + if ($next > 255) { + $next -= 255; + } elseif ($next < 0) { + $next += 255; + } + $tmp .= chr($next); + } + + return $tmp; } /** @@ -206,9 +379,11 @@ * @param string Login * @return string */ - function _incrementLoginChar3($login, $cpt) { + function _shuffle($login) { + + $tmp = array(); - for ($i=0; $i < strlen($login); $i++) { + for ($i = 0; $i < strlen($login); $i++) { $tmp[] = $login{$i}; } @@ -229,7 +404,7 @@ */ function _createPronounceable($length) { - global $_Text_Password_nbrCharacters; + global $_Text_Password_NumberOfPossibleCharacters; $retVal = ''; @@ -249,13 +424,10 @@ 'ch', 'ph', 'st', 'sl', 'cl' ); - /** - * XXX: Make this static! - */ - $v_count = count($v); - $c_count = count($c); + $v_count = 12; + $c_count = 29; - $_Text_Password_nbrCharacters = $v_count + $c_count; + $_Text_Password_NumberOfPossibleCharacters = $v_count + $c_count; for ($i = 0; $i < $length; $i++) { $retVal .= $c[mt_rand(0, $c_count-1)] . $v[mt_rand(0, $v_count-1)]; @@ -274,9 +446,9 @@ * @param string Character which could be use in the password ex : 'A,B,C,D,E,F,G' or numeric or alphanumeric * @return string Returns the password */ - function _createUnpronounceable($length, $chars) { // en cours + function _createUnpronounceable($length, $chars) { - global $_Text_Password_nbrCharacters; + global $_Text_Password_NumberOfPossibleCharacters; $password = ''; @@ -287,17 +459,17 @@ case 'alphanumeric': $regex = 'A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|0|1|2|3|4|5|6|7|8|9'; - $_Text_Password_nbrCharacters = 62; + $_Text_Password_NumberOfPossibleCharacters = 62; break; case 'numeric': $regex = '0|1|2|3|4|5|6|7|8|9'; - $_Text_Password_nbrCharacters = 10; + $_Text_Password_NumberOfPossibleCharacters = 10; break; case '': $regex = '_|#|@|%|£|&|ç|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|0|1|2|3|4|5|6|7|8|9'; - $_Text_Password_nbrCharacters = 69; + $_Text_Password_NumberOfPossibleCharacters = 69; break; default: @@ -318,7 +490,7 @@ } $regex = str_replace(',', '|', $chars); - $_Text_Password_nbrCharacters = strlen(str_replace(',', '', $chars)); + $_Text_Password_NumberOfPossibleCharacters = strlen(str_replace(',', '', $chars)); } /** Index: pear/Text_Password/package.xml diff -u pear/Text_Password/package.xml:1.2 pear/Text_Password/package.xml:1.3 --- pear/Text_Password/package.xml:1.2 Mon Nov 11 05:53:53 2002 +++ pear/Text_Password/package.xml Fri Jan 3 07:34:07 2003 @@ -30,6 +30,7 @@ <file role="php" baseinstalldir="Text">Password.php</file> <dir name="tests"> <file role="test">01-text-password.phpt</file> + <file role="test">02-html-password.phpt</file> </dir> </filelist> </release> Index: pear/Text_Password/tests/01-text-password.phpt diff -u pear/Text_Password/tests/01-text-password.phpt:1.3 pear/Text_Password/tests/01-text-password.phpt:1.4 --- pear/Text_Password/tests/01-text-password.phpt:1.3 Mon Nov 11 05:53:53 2002 +++ pear/Text_Password/tests/01-text-password.phpt Fri Jan 3 07:34:07 2003 @@ -5,9 +5,9 @@ function timeToBruteForce ($password, $nbr = 0, $cmbPerSeconde = 4000) { - global $_Text_Password_nbrCharacters; + global $_Text_Password_NumberOfPossibleCharacters; - $nbr = ($nbr == 0) ? $_Text_Password_nbrCharacters : $nbr; + $nbr = ($nbr == 0) ? $_Text_Password_NumberOfPossibleCharacters : $nbr; $cmb = pow($nbr, strlen($password)); $time_max = $cmb / $cmbPerSeconde; $time_min = ($cmb / $cmbPerSeconde) / 2; @@ -42,14 +42,32 @@ echo "\nCreating password from login 'olivier', type is 'reverse':\t"; echo Text_Password::createFromLogin('olivier', 'reverse') . "\n\n"; -echo "\nCreating password from login 'olivier', type is 'increment_char':\t"; -echo Text_Password::createFromLogin('olivier', 'increment_char', 1) . "\n\n"; +echo "\nCreating password from login 'olivier', type is 'rot13':\t"; +echo Text_Password::createFromLogin('olivier', 'rot13') . "\n\n"; -echo "\nCreating password from login 'olivier', type is 'increment_char2':\t"; -echo Text_Password::createFromLogin('olivier', 'increment_char2', 1) . "\n\n"; +echo "\nCreating password from login 'olivier', type is 'rotx':\t"; +echo Text_Password::createFromLogin('olivier', 'rotx', 13) . "\n\n"; -echo "\nCreating password from login 'olivier', type is 'increment_char3':\t"; -echo Text_Password::createFromLogin('olivier', 'increment_char3', 1) . "\n\n"; +echo "\nCreating password from login 'olivier', type is 'rotx++':\t"; +echo Text_Password::createFromLogin('olivier', 'rotx++', 13) . "\n\n"; + +echo "\nCreating password from login 'olivier', type is 'rotx--':\t"; +echo Text_Password::createFromLogin('olivier', 'rotx--', 13) . "\n\n"; + +echo "\nCreating password from login 'olivier', type is 'xor':\t"; +echo Text_Password::createFromLogin('olivier', 'xor', 5) . "\n\n"; + +echo "\nCreating password from login 'olivier', type is 'ascii_rotx':\t"; +echo Text_Password::createFromLogin('olivier', 'ascii_rotx', 5) . "\n\n"; + +echo "\nCreating password from login 'olivier', type is 'ascii_rotx++':\t"; +echo Text_Password::createFromLogin('olivier', 'ascii_rotx++', 5) . "\n\n"; + +echo "\nCreating password from login 'olivier', type is 'ascii_rotx--':\t"; +echo Text_Password::createFromLogin('olivier', 'ascii_rotx--', 5) . "\n\n"; + +echo "\nCreating password from login 'olivier', type is 'shuffle':\t"; +echo Text_Password::createFromLogin('olivier', 'shuffle', 1) . "\n\n"; echo "\nCreating password from an array of login 'olivier', 'martin', 'vanhoucke', 'jansen', type is 'reverse':\n"; $logins = array('olivier', 'martin', 'vanhoucke', 'jansen');