cvs: pear /Text_Password Password.php
| From: | Martin Jansen | Date: | Sun, 21 Aug 2005 19:44:09 +0000 |
| Subject: | cvs: pear /Text_Password Password.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-34203@lists.php.net to get a copy of this message | ||
mj Sun Aug 21 15:44:09 2005 EDT
Modified files:
/pear/Text_Password Password.php
Log:
* The functionality to check if a password is well choosen has never
matured. In order to not delay the release of version 1.1 any further,
I'm removing it for now.
http://cvs.php.net/diff.php/pear/Text_Password/Password.php?r1=1.14&r2=1.15&ty=u
Index: pear/Text_Password/Password.php
diff -u pear/Text_Password/Password.php:1.14 pear/Text_Password/Password.php:1.15
--- pear/Text_Password/Password.php:1.14 Sun Aug 21 15:39:49 2005
+++ pear/Text_Password/Password.php Sun Aug 21 15:44:06 2005
@@ -17,7 +17,7 @@
// | Olivier Vanhoucke <olivier@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: Password.php,v 1.14 2005/08/21 19:39:49 mj Exp $
+// $Id: Password.php,v 1.15 2005/08/21 19:44:06 mj Exp $
//
/**
@@ -166,89 +166,6 @@
}
/**
- * Check if the given password is well chosen
- *
- * This method tries to determine if the given password is well
- * chosen or not. If the crack library (http://pecl.php.net/package/crack)
- * is available, it's functionality will be utilized to determine
- * the quality grade. Otherwise the method will fall back on some
- * rather simplistic heuristical analysis.
- * Be aware that the crack library will produce much more accurate
- * results.
- *
- * @access public
- * @param string the password
- * @return boolean True, if the password is well chosen, otherwise false
- */
- function check($password)
- {
- // Todo: fall back on cracklib if it's loadable
-
- if (strlen($password) < 6) {
- return false;
- }
-
- if (!preg_match("/\d+/", $password)) {
- return false;
- }
-
- if (!preg_match("\w+/", $password)) {
- return false;
- }
-
- // No character must occur more than two times
- $count = array();
- $chars = preg_split("//", $password);
- foreach ($chars as $char) {
- if (empty($char)) {
- continue;
- }
-
- array_shift($chars);
-
- if (in_array($char, $chars)) {
- if (!isset($count[$char])) {
- $count[$char] = 1;
- } else {
- $count[$char]++;
- }
-
- if ($count[$char] > 2) {
- return false;
- }
- }
-
- }
-
- $cleaned = Text_Password::cleanJargon($password);
- if ($cleaned != $password) {
- return Text_Password::check($cleaned);
- }
-
- return true;
- }
-
- /**
- * Removes "jargon" terms from a given password
- *
- * This method transforms strings like "p4ssw0rd" into their
- * counterparts that do not abuse numbers for representing
- * characters. The above example would then become "password".
- *
- * @access public
- * @param string "Jargon-ized" Password
- * @return string Password without jargon terms.
- */
- function cleanJargon($password) {
- // Todo: to be extended. kids, anyone?
- $replacements = array("4" => "a",
- "3" => "e",
- "0" => "o");
-
- return str_replace(array_keys($replacements), array_values($replacements), $password);
- }
-
- /**
* Helper method to create password
*
* Method to create a password from a login