This commit is contained in:
2026-03-06 02:27:52 +08:00
parent f598cc8157
commit 70c4966aad
80 changed files with 796 additions and 1191 deletions
+28 -15
View File
@@ -26,15 +26,40 @@ class Encrypt
*/
static function userIDencode($userID,$key=0):string{
if(!is_numeric(($userID))){
return $userID;
return $userID.'';
}
$userID = intval($userID);
if($userID<=100234){
return $userID.'';
}
if($userID == '100235'){
return 'JWrb5JPm3E';
}
if($userID<=102028){
return id_encode($userID);
}
return self::intEncode($userID,$key);
}
/**
* 解密非连续数字ID为原始连续ID
* @param int $encryptedId 加密后的非连续ID8位数)
* @param int $userKey 可选的额外密钥
* @return int 原始连续ID
*/
static function userIDDecode($userID,$key=0):string{
if($userID == 'JWrb5JPm3E'){
return '100235';
}
if(!is_numeric(($userID))){
return id_decode($userID.'');
}
if($userID<=100234){
return $userID.'';
}
return self::intDecode($userID,$key);
}
static function intEncode($userID,$key=0){
$key = intval($key);
$plainId = abs(intval($userID)) % self::$maxId;
@@ -55,19 +80,8 @@ class Encrypt
// 确保结果是8位数(10000000 - 99999999
return (self::$baseValue + $encrypted).'';
}
/**
* 解密非连续数字ID为原始连续ID
* @param int $encryptedId 加密后的非连续ID8位数)
* @param int $userKey 可选的额外密钥
* @return int 原始连续ID
*/
static function userIDDecode($userID,$key=0):string{
if(!is_numeric(($userID))){
return id_decode($userID.'');
}
if($userID<=100234){
return $userID.'';
}
static function intDecode($userID,$key=0): string{
$key = intval($key);
// 去除基数,得到原始混淆值
$cipherId = ($userID - self::$baseValue + self::$maxId) % self::$maxId;
@@ -88,7 +102,6 @@ class Encrypt
return $plainId.'';
}
/**
* 使用扩展欧几里得算法计算模逆元
* 返回 x 使得 (a * x) % m = 1
-11
View File
@@ -9,18 +9,7 @@ declare(strict_types=1);
namespace support;
use FastRoute\BadRouteException;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use Throwable;
use Tinywan\ExceptionHandler\Event\DingTalkRobotEvent;
use Tinywan\ExceptionHandler\Exception\BaseException;
use Tinywan\ExceptionHandler\Exception\ServerErrorHttpException;
use Tinywan\Jwt\Exception\JwtRefreshTokenExpiredException;
use Tinywan\Jwt\Exception\JwtTokenException;
use Tinywan\Jwt\Exception\JwtTokenExpiredException;
use Tinywan\Validate\Exception\ValidateException;
use Webman\Exception\ExceptionHandler;
use Webman\Http\Request;
use Webman\Http\Response;
+7 -4
View File
@@ -69,7 +69,10 @@ class Utils
if ($token) {
$options[RequestOptions::HEADERS]['token'] = $token;
}
return post($uri,$data,[
"token: {$token}",
"operationID: {$options[RequestOptions::HEADERS]['operationID']}",
]);
return $client->post($uri, $options)->getBody()->getContents();
}
@@ -88,10 +91,10 @@ class Utils
$token = $token ? $token : Utils::getAdminToken();
}
$url = Url::buildUrl($path);
//log_alert($url);
//log_alert($data);
//cp($url);
//cp($data);
$res = self::request($url, $data, $token);
//log_alert($res);
//cp($res);
$res = json_decode($res, true);
if($res['errCode'] !==0 ){
throw new \Exception($res['errMsg'],$res['errCode']);