hyperf-chat/app/Helper/Hash.php

30 lines
557 B
PHP
Raw Normal View History

2020-11-05 17:40:51 +08:00
<?php
namespace App\Helper;
class Hash
{
/**
* Hash the given value.
*
* @param string $value
* @return string
*/
2020-11-14 23:05:45 +08:00
public static function make(string $value)
2020-11-05 17:40:51 +08:00
{
return password_hash($value, PASSWORD_DEFAULT);
}
/**
* Check the given plain value against a hash.
*
* @param string $value
* @param string $hashedValue
* @return bool
*/
2020-11-14 23:05:45 +08:00
public static function check(string $value, string $hashedValue)
2020-11-05 17:40:51 +08:00
{
return password_verify($value, $hashedValue);
}
}