You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.9 KiB
PHP

<?php
namespace App\Http\Controllers\API\Admin;
use App\Http\Controllers\Controller;
use App\Services\Login\LoginService;
use Illuminate\Http\Request;
use Yz;
use App\Lib\HSM;
use App\Lib\XTSign;
class LoginController extends Controller
{
public function Login(){
$username =request('username');
$password= request('password');
$username=$this->de_hunxiao($username);
$password=$this->de_hunxiao($password);
$login=app()->make(LoginService::class);
//$login= new LoginService();
return Yz::echo($login->Login(['username'=>$username,'password'=>$password]));
}
function de_hunxiao($str)
{
$decodedString = base64_decode($str);
// 第二步:移除固定的前缀和后缀
$strippedString = str_replace('a5331_', '', $decodedString);
$strippedString = str_replace('_a454d', '', $strippedString);
// 第三步:反转字符串以恢复原始顺序
$reversedString = strrev($strippedString);
// 第四步:字符替换(包括字母和数字)
$charMap = [
'z' => 'a', 'y' => 'b', 'x' => 'c', 'w' => 'd', 'v' => 'e',
'u' => 'f', 't' => 'g', 's' => 'h', 'r' => 'i', 'q' => 'j',
'p' => 'k', 'o' => 'l', 'n' => 'm', 'm' => 'n', 'l' => 'o',
'k' => 'p', 'j' => 'q', 'i' => 'r', 'h' => 's', 'g' => 't',
'f' => 'u', 'e' => 'v', 'd' => 'w', 'c' => 'x', 'b' => 'y',
'a' => 'z',
'@' => '0', '!' => '1', '#' => '2', '$' => '3', '%' => '4',
'^' => '5', '&' => '6', '*' => '7', '(' => '8', ')' => '9'
];
$originalString = '';
for ($i = 0; $i < strlen($reversedString); $i++) {
$char = $reversedString[$i];
$originalString .= isset($charMap[$char]) ? $charMap[$char] : $char;
}
// 输出解码后的字符串
return $originalString;
}
}