|
@@ -550,4 +550,62 @@ function get_request_origin(){ |
|
@@ -550,4 +550,62 @@ function get_request_origin(){ |
550
|
*/
|
550
|
*/
|
551
|
function abort(string $message = ''){
|
551
|
function abort(string $message = ''){
|
552
|
throw new Exception($message);
|
552
|
throw new Exception($message);
|
|
|
553
|
+}
|
|
|
554
|
+
|
|
|
555
|
+/**
|
|
|
556
|
+ * 加密base64
|
|
|
557
|
+ * @param string $str
|
|
|
558
|
+ * @return string 第一位是随机数长度 后N位是随机数 后面是加密的数字组合 统一个字符串的组合根据随机数的长度而定
|
|
|
559
|
+ * @author:dc
|
|
|
560
|
+ * @time 2024/12/20 11:21
|
|
|
561
|
+ */
|
|
|
562
|
+function base64_en_md5(string $str){
|
|
|
563
|
+ $str = base64_encode($str);
|
|
|
564
|
+ $r = rand(12,30); // TODO::随机数最低不能小于10
|
|
|
565
|
+ $enStr = '*********************************************';
|
|
|
566
|
+ $enStr = substr($enStr,0,$r).'0123456789+qwertyuiopasdfghjklzxcvbnm/QWERTYUIOPASDFGHJKLZXCVBNM';
|
|
|
567
|
+ $enStr = str_split($enStr);
|
|
|
568
|
+ foreach ($enStr as $k=>$e){
|
|
|
569
|
+ if($e=='*'){
|
|
|
570
|
+ unset($enStr[$k]);
|
|
|
571
|
+ }
|
|
|
572
|
+ }
|
|
|
573
|
+ $enStr = array_flip($enStr);
|
|
|
574
|
+ $strs = array_map(function ($v) use ($enStr){
|
|
|
575
|
+ if($v=='='){
|
|
|
576
|
+ return '';
|
|
|
577
|
+ }
|
|
|
578
|
+ return $enStr[$v];
|
|
|
579
|
+ },str_split($str));
|
|
|
580
|
+
|
|
|
581
|
+ return (string) strlen((string) $r).$r.implode('',$strs);
|
|
|
582
|
+}
|
|
|
583
|
+
|
|
|
584
|
+/**
|
|
|
585
|
+ * 解密 base64
|
|
|
586
|
+ * @param string $str
|
|
|
587
|
+ * @return false|string
|
|
|
588
|
+ * @author:dc
|
|
|
589
|
+ * @time 2024/12/20 11:51
|
|
|
590
|
+ */
|
|
|
591
|
+function base64_de_md5(string $str){
|
|
|
592
|
+ $f = substr($str,0,1);
|
|
|
593
|
+ $r = substr($str,1,$f);
|
|
|
594
|
+ $enStr = '*********************************************';
|
|
|
595
|
+ $enStr = substr($enStr,0,$r).'0123456789+qwertyuiopasdfghjklzxcvbnm/QWERTYUIOPASDFGHJKLZXCVBNM';
|
|
|
596
|
+ $enStr = str_split($enStr);
|
|
|
597
|
+ foreach ($enStr as $k=>$e){
|
|
|
598
|
+ if($e=='*'){
|
|
|
599
|
+ unset($enStr[$k]);
|
|
|
600
|
+ }
|
|
|
601
|
+ }
|
|
|
602
|
+
|
|
|
603
|
+ $str = substr($str,$f+1);
|
|
|
604
|
+
|
|
|
605
|
+ $strs = array_map(function ($v) use ($enStr){
|
|
|
606
|
+ return $enStr[$v];
|
|
|
607
|
+ },str_split($str,$f));
|
|
|
608
|
+
|
|
|
609
|
+ return base64_decode(implode('',$strs).'==');
|
|
|
610
|
+
|
553
|
} |
611
|
} |