mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-26 20:52:44 +08:00
28 lines
444 B
PHP
28 lines
444 B
PHP
<?php
|
|
|
|
namespace App\Library\Util;
|
|
|
|
use Phalcon\Text;
|
|
|
|
class Password
|
|
{
|
|
|
|
public static function salt()
|
|
{
|
|
return Text::random();
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
}
|