Browse Source

更新加密解密函数

Anyon 8 years ago
parent
commit
588ea187e6
2 changed files with 6 additions and 4 deletions
  1. 3 3
      application/common.php
  2. 3 1
      application/route.php

+ 3 - 3
application/common.php

@@ -38,7 +38,7 @@ function & load_wechat($type = '') {
  * @return string
  */
 function encode($data) {
-    return str_replace(array('+', '/', '='), array('-', '_', ''), base64_encode(serialize($data)));
+    return str_replace(['+', '/', '='], ['-', '_', ''], base64_encode(serialize($data)));
 }
 
 /**
@@ -47,9 +47,9 @@ function encode($data) {
  * @return string
  */
 function decode($string) {
-    $data = str_replace(array('-', '_'), array('+', '/'), $string);
+    $data = str_replace(['-', '_'], ['+', '/'], $string);
     $mod4 = strlen($data) % 4;
-    ($mod4) && $data .= substr('====', $mod4);
+    !!$mod4 && $data .= substr('====', $mod4);
     return unserialize(base64_decode($data));
 }
 

+ 3 - 1
application/route.php

@@ -9,4 +9,6 @@
 // | Author: liu21st <liu21st@gmail.com>
 // +----------------------------------------------------------------------
 
-return [];
+return [
+    ':a-:b$' => ':1/:b'
+];