Jelajahi Sumber

完善播放记录aes加密

15954078560 2 tahun lalu
induk
melakukan
e961166748
1 mengubah file dengan 16 tambahan dan 1 penghapusan
  1. 16 1
      application/api/controller/Index.php

+ 16 - 1
application/api/controller/Index.php

@@ -1249,6 +1249,21 @@ class Index extends Api
         $this->success('详情', $info);
     }
 
+    /** * * @param string $string 需要加密的字符串 * @param string $key 密钥 * @return string */
+    public function encrypt($string, $key) {
+//        $key = substr(openssl_digest(openssl_digest($key, 'sha1', true), 'sha1', true), 0, 16);
+        $data = openssl_encrypt($string, 'AES-128-ECB', $key, OPENSSL_RAW_DATA);
+        $data = bin2hex($data);
+        return $data;
+    }
+
+    /** * @param string $string 需要解密的字符串 * @param string $key 密钥 * @return string */
+    public function decrypt($string, $key) {
+//        $key = substr(openssl_digest(openssl_digest($key, 'sha1', true), 'sha1', true), 0, 16);
+        $decrypted = openssl_decrypt(hex2bin($string), 'AES-128-ECB', $key, OPENSSL_RAW_DATA);
+        return $decrypted;
+    }
+
     //视频播放记录
     public function playrecord() {
         $id = input('id', 0, 'intval');
@@ -1288,7 +1303,7 @@ class Index extends Api
             'endWatchTime' => $end_time,
             'playTime' => $end_time - $start_time,
             'logType' => $log_type,
-            'account' => aes_en($this->auth->mobile),
+            'account' => $this->encrypt($this->auth->mobile, '!@#$%^&*FJGFJT78'),
             'cpPermission' => 'GITV',
             'intent' => [
                 'action' => 'com.huxiu.heh.tv.ui.video.detail.VideoDetailActivity',