| @@ 244-256 (lines=13) @@ | ||
| 241 | * Generate a hash for user login |
|
| 242 | * @param string $password |
|
| 243 | */ |
|
| 244 | function bCrypt($password, $cost) |
|
| 245 | { |
|
| 246 | $salt = sprintf('$2y$%02d$', $cost); |
|
| 247 | if (function_exists('openssl_random_pseudo_bytes')) { |
|
| 248 | $salt .= bin2hex(openssl_random_pseudo_bytes(11)); |
|
| 249 | } else { |
|
| 250 | $chars = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
|
| 251 | for ($i = 0; $i < 22; $i++) { |
|
| 252 | $salt .= $chars[mt_rand(0, 63)]; |
|
| 253 | } |
|
| 254 | } |
|
| 255 | return crypt($password, $salt); |
|
| 256 | } |
|
| 257 | ||
| 258 | function cryption_before_defuse($message, $sk, $iv, $type = null, $scope = "public") |
|
| 259 | { |
|
| @@ 58-70 (lines=13) @@ | ||
| 55 | * Generate a hash for user login |
|
| 56 | * @param string $password |
|
| 57 | */ |
|
| 58 | function bCrypt($password, $cost) |
|
| 59 | { |
|
| 60 | $salt = sprintf('$2y$%02d$', $cost); |
|
| 61 | if (function_exists('openssl_random_pseudo_bytes')) { |
|
| 62 | $salt .= bin2hex(openssl_random_pseudo_bytes(11)); |
|
| 63 | } else { |
|
| 64 | $chars = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
|
| 65 | for ($i = 0; $i < 22; $i++) { |
|
| 66 | $salt .= $chars[mt_rand(0, 63)]; |
|
| 67 | } |
|
| 68 | } |
|
| 69 | return crypt($password, $salt); |
|
| 70 | } |
|
| 71 | ||
| 72 | if (isset($_POST['type'])) { |
|
| 73 | switch ($_POST['type']) { |
|