1
This commit is contained in:
46
application/api/controller/EmailService.php
Normal file
46
application/api/controller/EmailService.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\controller\Base;
|
||||
use think\Db;
|
||||
use think\Queue;
|
||||
use think\Env;
|
||||
use think\Validate;
|
||||
|
||||
class EmailService extends Base
|
||||
{
|
||||
|
||||
public function __construct(\think\Request $request = null)
|
||||
{
|
||||
parent::__construct($request);
|
||||
}
|
||||
|
||||
public function refusePassword()
|
||||
{
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"password" => "require"
|
||||
]);
|
||||
if (!$rule->check($data)) {
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$password = $data['password'];
|
||||
if (function_exists('openssl_random_pseudo_bytes')) {
|
||||
$salt = substr(str_replace('+', '.', base64_encode(openssl_random_pseudo_bytes(6))), 0, 8);
|
||||
} else {
|
||||
// 使用 mt_rand 作为后备方法
|
||||
$salt = '';
|
||||
for ($i = 0; $i < 8; $i++) {
|
||||
$salt .= chr(mt_rand(33, 126)); // 生成随机字符
|
||||
}
|
||||
}
|
||||
$hashed_password = crypt($password, '$1$' . $salt . '$');
|
||||
|
||||
return jsonSuccess(["result"=>$hashed_password]);
|
||||
|
||||
// return $hashed_password;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user