mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-22 11:41:27 +08:00
28 lines
466 B
PHP
28 lines
466 B
PHP
<?php
|
|
|
|
namespace App\Library\Utils;
|
|
|
|
use Phalcon\Text;
|
|
|
|
class Password
|
|
{
|
|
|
|
public static function salt()
|
|
{
|
|
return Text::random(Text::RANDOM_ALNUM, 8);
|
|
}
|
|
|
|
public static function hash($password, $salt)
|
|
{
|
|
return md5(md5($password) . md5($salt));
|
|
}
|
|
|
|
public static function checkHash($password, $salt, $passwordHash)
|
|
{
|
|
$inputHash = self::hash($password, $salt);
|
|
|
|
return $inputHash == $passwordHash;
|
|
}
|
|
|
|
}
|