equal
deleted
inserted
replaced
1 <?php |
1 <?php |
2 /** |
2 /** |
3 * Portable PHP password hashing framework. |
3 * Portable PHP password hashing framework. |
4 * @package phpass |
4 * @package phpass |
5 * @since 2.5 |
5 * @since 2.5.0 |
6 * @version 0.3 / WordPress |
6 * @version 0.3 / WordPress |
7 * @link http://www.openwall.com/phpass/ |
7 * @link http://www.openwall.com/phpass/ |
8 */ |
8 */ |
9 |
9 |
10 # |
10 # |
29 * Portable PHP password hashing framework. |
29 * Portable PHP password hashing framework. |
30 * |
30 * |
31 * @package phpass |
31 * @package phpass |
32 * @version 0.3 / WordPress |
32 * @version 0.3 / WordPress |
33 * @link http://www.openwall.com/phpass/ |
33 * @link http://www.openwall.com/phpass/ |
34 * @since 2.5 |
34 * @since 2.5.0 |
35 */ |
35 */ |
36 class PasswordHash { |
36 class PasswordHash { |
37 var $itoa64; |
37 var $itoa64; |
38 var $iteration_count_log2; |
38 var $iteration_count_log2; |
39 var $portable_hashes; |
39 var $portable_hashes; |
212 return $output; |
212 return $output; |
213 } |
213 } |
214 |
214 |
215 function HashPassword($password) |
215 function HashPassword($password) |
216 { |
216 { |
|
217 if ( strlen( $password ) > 4096 ) { |
|
218 return '*'; |
|
219 } |
|
220 |
217 $random = ''; |
221 $random = ''; |
218 |
222 |
219 if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) { |
223 if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) { |
220 $random = $this->get_random_bytes(16); |
224 $random = $this->get_random_bytes(16); |
221 $hash = |
225 $hash = |
247 return '*'; |
251 return '*'; |
248 } |
252 } |
249 |
253 |
250 function CheckPassword($password, $stored_hash) |
254 function CheckPassword($password, $stored_hash) |
251 { |
255 { |
|
256 if ( strlen( $password ) > 4096 ) { |
|
257 return false; |
|
258 } |
|
259 |
252 $hash = $this->crypt_private($password, $stored_hash); |
260 $hash = $this->crypt_private($password, $stored_hash); |
253 if ($hash[0] == '*') |
261 if ($hash[0] == '*') |
254 $hash = crypt($password, $stored_hash); |
262 $hash = crypt($password, $stored_hash); |
255 |
263 |
256 return $hash === $stored_hash; |
264 return $hash === $stored_hash; |