소스 검색

加密方法更改

linwu 2 년 전
부모
커밋
ecee94a5cb
2개의 변경된 파일7개의 추가작업 그리고 14개의 파일을 삭제
  1. 1 3
      app/admin/controller/Comjobs.php
  2. 6 11
      app/common/service/RensheService.php

+ 1 - 3
app/admin/controller/Comjobs.php

@@ -538,7 +538,7 @@ class Comjobs extends BaseController
         $item['aae100']  = $info['status'] == 3 ? 1 : 0;
         $item['bcz015']  = $info['longitude'];
         $item['bcz016']  = $info['latitude'];
-//        $item['bye002']  = $info['updatetime'];
+        $item['bye002']  = $info['updatetime'];
         $list[]          = array_filter($item);
         $send['list']    = $list;
 
@@ -557,6 +557,4 @@ class Comjobs extends BaseController
             ]);
         }
     }
-
-
 }

+ 6 - 11
app/common/service/RensheService.php

@@ -17,8 +17,6 @@ class RensheService
 
     //要发送的数据
     private $_data = [];
-    //sm4对象
-    private $_sm4Obj = null;
     //当前时间
     private $_time = 0;
 
@@ -28,9 +26,8 @@ class RensheService
      */
     public function __construct($data = [])
     {
-        $this->_data   = $data;
-        $this->_sm4Obj = new Sm4(self::KEY, self::IV);
-        $this->_time   = date('YmdHis');
+        $this->_data = $data;
+        $this->_time = date('YmdHis');
     }
 
     /**
@@ -62,9 +59,7 @@ class RensheService
     private function _enDataCbc()
     {
         $data = $this->_time . json_encode($this->_data);
-        $res  = $this->_sm4Obj->encrypt($data);
-
-        return $res;
+        return base64_encode(openssl_encrypt($data, "sm4", self::KEY, 0, self::IV));
     }
 
     /**
@@ -74,9 +69,9 @@ class RensheService
      */
     private function _deDataCbc($data)
     {
-        $res = $this->_sm4Obj->decrypt($data);
+        $res = openssl_decrypt(base64_decode($data), "sm4", self::KEY, 0, self::IV);
         if ($res[0] != "{") {
-            $res = mb_substr($res,14,strlen($res),'UTF-8');
+            $res = mb_substr($res, 14, strlen($res), 'UTF-8');
         }
 
         return json_decode($res, true);
@@ -90,7 +85,7 @@ class RensheService
     private function _send($url)
     {
         //请求头
-        $enTime = $this->_sm4Obj->encrypt($this->_time);
+        $enTime = base64_encode(openssl_encrypt($this->_time, "sm4", self::KEY, 0, self::IV));
         $header = [
             'Content-Type: application/json',
             'Author-source: 1',