| @@ 59-71 (lines=13) @@ | ||
| 56 | * Generate a hash for user login |
|
| 57 | * @param string $password |
|
| 58 | */ |
|
| 59 | function bCrypt($password, $cost) |
|
| 60 | { |
|
| 61 | $salt = sprintf('$2y$%02d$', $cost); |
|
| 62 | if (function_exists('openssl_random_pseudo_bytes')) { |
|
| 63 | $salt .= bin2hex(openssl_random_pseudo_bytes(11)); |
|
| 64 | } else { |
|
| 65 | $chars = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
|
| 66 | for ($i = 0; $i < 22; $i++) { |
|
| 67 | $salt .= $chars[mt_rand(0, 63)]; |
|
| 68 | } |
|
| 69 | } |
|
| 70 | return crypt($password, $salt); |
|
| 71 | } |
|
| 72 | ||
| 73 | if (isset($_POST['type'])) { |
|
| 74 | switch ($_POST['type']) { |
|
| @@ 259-271 (lines=13) @@ | ||
| 256 | * Generate a hash for user login |
|
| 257 | * @param string $password |
|
| 258 | */ |
|
| 259 | function bCrypt($password, $cost) |
|
| 260 | { |
|
| 261 | $salt = sprintf('$2y$%02d$', $cost); |
|
| 262 | if (function_exists('openssl_random_pseudo_bytes')) { |
|
| 263 | $salt .= bin2hex(openssl_random_pseudo_bytes(11)); |
|
| 264 | } else { |
|
| 265 | $chars = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
|
| 266 | for ($i = 0; $i < 22; $i++) { |
|
| 267 | $salt .= $chars[mt_rand(0, 63)]; |
|
| 268 | } |
|
| 269 | } |
|
| 270 | return crypt($password, $salt); |
|
| 271 | } |
|
| 272 | ||
| 273 | function cryption_before_defuse($message, $sk, $iv, $type = null, $scope = "public") |
|
| 274 | { |
|