...
|
...
|
@@ -550,4 +550,62 @@ function get_request_origin(){ |
|
|
*/
|
|
|
function abort(string $message = ''){
|
|
|
throw new Exception($message);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 加密base64
|
|
|
* @param string $str
|
|
|
* @return string 第一位是随机数长度 后N位是随机数 后面是加密的数字组合 统一个字符串的组合根据随机数的长度而定
|
|
|
* @author:dc
|
|
|
* @time 2024/12/20 11:21
|
|
|
*/
|
|
|
function base64_en_md5(string $str){
|
|
|
$str = base64_encode($str);
|
|
|
$r = rand(12,30); // TODO::随机数最低不能小于10
|
|
|
$enStr = '*********************************************';
|
|
|
$enStr = substr($enStr,0,$r).'0123456789+qwertyuiopasdfghjklzxcvbnm/QWERTYUIOPASDFGHJKLZXCVBNM';
|
|
|
$enStr = str_split($enStr);
|
|
|
foreach ($enStr as $k=>$e){
|
|
|
if($e=='*'){
|
|
|
unset($enStr[$k]);
|
|
|
}
|
|
|
}
|
|
|
$enStr = array_flip($enStr);
|
|
|
$strs = array_map(function ($v) use ($enStr){
|
|
|
if($v=='='){
|
|
|
return '';
|
|
|
}
|
|
|
return $enStr[$v];
|
|
|
},str_split($str));
|
|
|
|
|
|
return (string) strlen((string) $r).$r.implode('',$strs);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 解密 base64
|
|
|
* @param string $str
|
|
|
* @return false|string
|
|
|
* @author:dc
|
|
|
* @time 2024/12/20 11:51
|
|
|
*/
|
|
|
function base64_de_md5(string $str){
|
|
|
$f = substr($str,0,1);
|
|
|
$r = substr($str,1,$f);
|
|
|
$enStr = '*********************************************';
|
|
|
$enStr = substr($enStr,0,$r).'0123456789+qwertyuiopasdfghjklzxcvbnm/QWERTYUIOPASDFGHJKLZXCVBNM';
|
|
|
$enStr = str_split($enStr);
|
|
|
foreach ($enStr as $k=>$e){
|
|
|
if($e=='*'){
|
|
|
unset($enStr[$k]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$str = substr($str,$f+1);
|
|
|
|
|
|
$strs = array_map(function ($v) use ($enStr){
|
|
|
return $enStr[$v];
|
|
|
},str_split($str,$f));
|
|
|
|
|
|
return base64_decode(implode('',$strs).'==');
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|