Hi,
na dann schau dir doch einfach an was die hash Methode macht und übernimm sie 1:1 in dein kleines Script
PHP-Code:
/**
* Generate a password hash
*
* @param string $strPassword The unencrypted password
*
* @return string The encrypted password
*
* @throws \Exception If none of the algorithms is available
*/
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');
}
Lesezeichen