From 2e661027ab13e391c5c12d55d91d3629d3cac192 Mon Sep 17 00:00:00 2001 From: bnu Date: Tue, 10 Mar 2015 11:21:40 +0900 Subject: [PATCH] =?UTF-8?q?445a414=20=EC=97=90=EC=84=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=ED=95=9C=20Password::=20generateStrongPassword()=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/security/Password.class.php | 78 ----------------------------- 1 file changed, 78 deletions(-) diff --git a/classes/security/Password.class.php b/classes/security/Password.class.php index 39407b97b..cef8c9158 100644 --- a/classes/security/Password.class.php +++ b/classes/security/Password.class.php @@ -380,84 +380,6 @@ class Password } return $diff === 0; } - - /** - * @brief Generates a strong password - * - * @param int $length - * @param bool $add_dashes - * @param string $available_sets - * @return string - * - * @link https://gist.github.com/tylerhall/521810 - * - * Generates a strong password of N length containing at least one lower case letter, - * one uppercase letter, one digit, and one special character. The remaining characters - * in the password are chosen at random from those four sets. - * - * The available characters in each set are user friendly - there are no ambiguous - * characters such as i, l, 1, o, 0, etc. This, coupled with the $add_dashes option, - * makes it much easier for users to manually type or speak their passwords. - * - * Note: the $add_dashes option will increase the length of the password by - * floor(sqrt(N)) characters. - */ - function generateStrongPassword($length = 10, $add_dashes = false, $available_sets = 'luds') - { - $sets = array(); - if(strpos($available_sets, 'l') !== false) - { - $sets[] = 'abcdefghjkmnpqrstuvwxyz'; - } - - if(strpos($available_sets, 'u') !== false) - { - $sets[] = 'ABCDEFGHJKMNPQRSTUVWXYZ'; - } - - if(strpos($available_sets, 'd') !== false) - { - $sets[] = '23456789'; - } - - if(strpos($available_sets, 's') !== false) - { - $sets[] = '!@#$%&*?'; - } - - $all = ''; - $password = ''; - foreach($sets as $set) - { - $password .= $set[array_rand(str_split($set))]; - $all .= $set; - } - - $all = str_split($all); - for($i = 0; $i < $length - count($sets); $i++) - { - $password .= $all[array_rand($all)]; - } - - $password = str_shuffle($password); - - if(!$add_dashes) - { - return $password; - } - - $dash_len = floor(sqrt($length)); - $dash_str = ''; - while(strlen($password) > $dash_len) - { - $dash_str .= substr($password, 0, $dash_len) . '-'; - $password = substr($password, $dash_len); - } - - $dash_str .= $password; - - return $dash_str; - } } /* End of file : Password.class.php */ /* Location: ./classes/security/Password.class.php */