123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php namespace Laravel;
- class Hash {
-
- public static function check($value, $hash)
- {
- return crypt($value, $hash) === $hash;
- }
-
- public static function make($value, $rounds = 8)
- {
- $work = str_pad($rounds, 2, '0', STR_PAD_LEFT);
-
-
-
-
- if (function_exists('openssl_random_pseudo_bytes'))
- {
- $salt = openssl_random_pseudo_bytes(16);
- }
- else
- {
- $salt = Str::random(40);
- }
- $salt = substr(strtr(base64_encode($salt), '+', '.'), 0 , 22);
- return crypt($value, '$2a$'.$work.'$'.$salt);
- }
- }
|