public static function hash($strPassword)
{
$intCost = \Config::get('bcryptCost') ?: 10;
if ($intCost < 4 || $intCost > 31) {
throw new \Exception("The bcrypt cost has to be between 4 and 31, {$intCost} given");
}
if (function_exists('password_hash')) {
return password_hash($strPassword, PASSWORD_BCRYPT, array('cost' => $intCost));
} elseif (CRYPT_BLOWFISH == 1) {
return crypt($strPassword, '$2y$' . sprintf('%02d', $intCost) . '$' . md5(uniqid(mt_rand(), true)) . '$');
} elseif (CRYPT_SHA512 == 1) {
return crypt($strPassword, '$6$' . md5(uniqid(mt_rand(), true)) . '$');
} elseif (CRYPT_SHA256 == 1) {
return crypt($strPassword, '$5$' . md5(uniqid(mt_rand(), true)) . '$');
}
throw new \Exception('None of the required crypt() algorithms is available');
}