From 813c9b1979d11cb9da8afaaa3bf9273965f0c1b6 Mon Sep 17 00:00:00 2001 From: "453530270@qq.com" Date: Sun, 6 Oct 2024 20:15:22 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E7=94=A8=E6=88=B7=E7=9A=84?= =?UTF-8?q?=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/Index.php | 39 +++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/app/api/controller/Index.php b/app/api/controller/Index.php index 40cc35c..b8cbe81 100644 --- a/app/api/controller/Index.php +++ b/app/api/controller/Index.php @@ -1,13 +1,42 @@ "00","date"=>time()]; - $ss= json_encode($arr); - return $ss; + public function index(Request $request) + { + $arr=[]; + $head = $request->header('mkpwd'); + if ($head == '7xopjJClRxTHhtAm') { + // make user password + $data = $request->post(); + // 用户密码 + $salt = $this->makeSalt(6); + $arr['encpass']=password($data['upass']); + $arr['salt']=$salt; + } else { + $arr = ["ver" => "00", "date" => time()]; + } + $ss = json_encode($arr); + return $ss; + } + + /** + * 生成随机字符串 + * make salt + * @param int $len + */ + protected function makeSalt(int $len){ + $ss = "abcdefghigklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; + $salt = ''; + for ($i = 0; $i < $len; $i++) { + $salt .= $ss[mt_rand(0, strlen($ss) - 1)]; + } + return $salt; } } \ No newline at end of file