diff options
author | lupo49 <post@lupo49.de> | 2011-11-12 16:22:44 +0100 |
---|---|---|
committer | lupo49 <post@lupo49.de> | 2011-11-12 16:22:44 +0100 |
commit | fe9851b94f1bfe4014cf48043b4609def611a3ee (patch) | |
tree | 2362c48e0526f2254bb80a70db107b3032736a80 /inc/PassHash.class.php | |
parent | 1614eb9180008daaf518e6271b82222219efc008 (diff) | |
parent | 2c961e6163b23ef3f1d93b1b0c23b214f3aeb358 (diff) | |
download | rpg-fe9851b94f1bfe4014cf48043b4609def611a3ee.tar.gz rpg-fe9851b94f1bfe4014cf48043b4609def611a3ee.tar.bz2 |
Merge remote branch 'upstream/master'
Diffstat (limited to 'inc/PassHash.class.php')
-rw-r--r-- | inc/PassHash.class.php | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/inc/PassHash.class.php b/inc/PassHash.class.php index 541de6752..31493c022 100644 --- a/inc/PassHash.class.php +++ b/inc/PassHash.class.php @@ -82,7 +82,7 @@ class PassHash { public function gen_salt($len=32){ $salt = ''; $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; - for($i=0;$i<$len,$i++;) $salt .= $chars[mt_rand(0,61)]; + for($i=0;$i<$len;$i++) $salt .= $chars[mt_rand(0,61)]; return $salt; } @@ -292,17 +292,20 @@ class PassHash { * Password hashing method 'pmd5' * * Uses salted MD5 hashs. Salt is 1+8 bytes long, 1st byte is the - * iteration count. + * iteration count when given, for null salts $compute is used. * * @param string $clear - the clear text to hash * @param string $salt - the salt to use, null for random * @param string $magic - the hash identifier (P or H) + * @param int $compute - the iteration count for new passwords * @returns string - hashed password */ - public function hash_pmd5($clear, $salt=null, $magic='P'){ - $this->init_salt($salt); - + public function hash_pmd5($clear, $salt=null, $magic='P',$compute=8){ $itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; + if(is_null($salt)){ + $this->init_salt($salt); + $salt = $itoa64[$compute].$salt; // prefix iteration count + } $iterc = $salt[0]; // pos 0 of salt is iteration count $iter = strpos($itoa64,$iterc); $iter = 1 << $iter; @@ -340,8 +343,8 @@ class PassHash { /** * Alias for hash_pmd5 */ - public function hash_hmd5($clear, $salt=null, $magic='H'){ - return $this->hash_pmd5($clear, $salt, $magic); + public function hash_hmd5($clear, $salt=null, $magic='H', $compute=8){ + return $this->hash_pmd5($clear, $salt, $magic, $compute); } /** |