@@ -21,6 +21,11 @@ |
||
| 21 | 21 | return crypt($plaintext, $ciphertext) == $ciphertext; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | + /** |
|
| 25 | + * @param integer $cost |
|
| 26 | + * @param integer $length |
|
| 27 | + * @param string $bcrypt_version |
|
| 28 | + */ |
|
| 24 | 29 | public static function generate_salt($cost, $length, $bcrypt_version){ |
| 25 | 30 | //make sure adding the cost in two digits |
| 26 | 31 | $cost = sprintf('%02d', $cost); |
@@ -15,13 +15,14 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | public static function verify($plaintext, $ciphertext) |
| 17 | 17 | { |
| 18 | - if(version_compare(PHP_VERSION, '5.6.0', '>=')){ |
|
| 18 | + if(version_compare(PHP_VERSION, '5.6.0', '>=')) { |
|
| 19 | 19 | return hash_equals($ciphertext, crypt($plaintext, $ciphertext)); |
| 20 | 20 | } |
| 21 | 21 | return crypt($plaintext, $ciphertext) == $ciphertext; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - public static function generate_salt($cost, $length, $bcrypt_version){ |
|
| 24 | + public static function generate_salt($cost, $length, $bcrypt_version) |
|
| 25 | + { |
|
| 25 | 26 | //make sure adding the cost in two digits |
| 26 | 27 | $cost = sprintf('%02d', $cost); |
| 27 | 28 | |
@@ -31,7 +32,7 @@ discard block |
||
| 31 | 32 | * 22 base64 characters |
| 32 | 33 | */ |
| 33 | 34 | $bytes = openssl_random_pseudo_bytes($length); |
| 34 | - if ($bytes === false){ |
|
| 35 | + if ($bytes === false) { |
|
| 35 | 36 | throw new RuntimeException('Unable to generate a random string'); |
| 36 | 37 | } |
| 37 | 38 | $salt=substr(base64_encode($bytes),0,22); |