42 lines
699 B
PHP
42 lines
699 B
PHP
<?php
|
|
|
|
namespace App\Lib\Crypto;
|
|
|
|
use Exception;
|
|
|
|
class AdminPasswordCrypto implements CryptoInterface
|
|
{
|
|
/**
|
|
* 明文密码
|
|
* @var string
|
|
*/
|
|
public string $data = '';
|
|
|
|
/**
|
|
* 加密盐
|
|
* @var string
|
|
*/
|
|
public string $salt = '';
|
|
|
|
/**
|
|
* admin password 加密
|
|
* @return string
|
|
*/
|
|
public function encrypt(): string
|
|
{
|
|
try {
|
|
return hash("sha256", $this->salt . hash("sha256", $this->salt . $this->data));
|
|
} catch (Exception) {
|
|
return '';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 解密 不需要解密
|
|
* @return string
|
|
*/
|
|
public function decrypt(): string
|
|
{
|
|
return '';
|
|
}
|
|
} |