first commit

This commit is contained in:
annnj-company
2026-04-17 18:29:53 +08:00
parent e49fa5a215
commit 130c1026c4
5615 changed files with 1639145 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
<?php
namespace app\util;
use think\facade\Cache;
class BOCSign {
/**
* md5 加密
*/
public static function serPassword($data){
return md5($data,\config('api.password_pre_halt'));
}
/**
* 生成每次请求Sign字符串
*/
public static function setSign($data = []) {
// 按字段排序
\ksort($data);
//拼接字符串数据
$string = \http_build_query($data);
//通过 aes 来加密
$string = (new Aes(\config('api.aes_key')))->aesEn($string);
return $string;
}
/**
* 检测sign是否正常
*/
public static function checkSignPass($data) {
$str = (new Aes(\config('api.aes_key')))->aesDe($data);
// 判断解析出来的数据是否为空
if(empty($str)){
return false;
}
// 字符串转数组
parse_str($str,$arr);
// 判断是否是数组,数组内的字段是否正确
if(!\is_array($arr) || empty($arr['mg'])){
return false;
}
// 检测缓存,如果有缓存,说明这个sign已经被使用
if(Cache::get($data)){
return false;
}
return true;
}
/**
*'aes_key' =>[
* 'key' => 'reter4446fdfgdfgdfg', //加密key这个可以随便定义
* 'iv' => md5(time(). uniqid(),true), //保证偏移量为16位
* 'method' => 'AES-128-CBC' //加密方式 # AES-256-CBC等这个可以搭配的形式有很多具体的你可以去了解一下AES加密算法
* ],
*/
}