@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | $salt = self::generate_salt($cost, 17, $bcrypt_version); |
| 11 | 11 | $ciphertext = crypt($plaintext, $salt); |
| 12 | 12 | |
| 13 | - return $ciphertext; |
|
| 13 | + return $ciphertext; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | public static function verify($plaintext, $ciphertext) |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | $bytes = openssl_random_pseudo_bytes($length); |
| 34 | 34 | if ($bytes === false){ |
| 35 | - throw new RuntimeException('Unable to generate a random string'); |
|
| 35 | + throw new RuntimeException('Unable to generate a random string'); |
|
| 36 | 36 | } |
| 37 | 37 | $salt=substr(base64_encode($bytes),0,22); |
| 38 | 38 | |
@@ -41,12 +41,12 @@ discard block |
||
| 41 | 41 | * anything about the '=', as this only occurs when the b64 string is |
| 42 | 42 | * padded, which is always after the first 22 characters. |
| 43 | 43 | */ |
| 44 | - $salt=str_replace("+",".",$salt); |
|
| 44 | + $salt=str_replace("+",".",$salt); |
|
| 45 | 45 | |
| 46 | - /* Create a string that will be passed to crypt, containing all |
|
| 46 | + /* Create a string that will be passed to crypt, containing all |
|
| 47 | 47 | * of the settings, separated by dollar signs |
| 48 | 48 | */ |
| 49 | - $salt='$'.implode('$',[$bcrypt_version, $cost, $salt]); |
|
| 49 | + $salt='$'.implode('$',[$bcrypt_version, $cost, $salt]); |
|
| 50 | 50 | return $salt; |
| 51 | 51 | } |
| 52 | 52 | } |
@@ -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); |