浏览代码

Merge branch 'master' of http://47.101.159.18:3000/Muchinfo/MTP2.0_WEB

huangbin 4 年之前
父节点
当前提交
f72c2674b5
共有 1 个文件被更改,包括 14 次插入0 次删除
  1. 14 0
      src/utils/websocket/crypto/index.ts

+ 14 - 0
src/utils/websocket/crypto/index.ts

@@ -150,3 +150,17 @@ export const decrypt50 = (encryptData: Uint8Array, size: number): Uint8Array | n
 
     return a.subarray(0, size);
 };
+
+/**
+ * AES数据解密方法
+ * @param encryptData 密文
+ * @param size 明文长度
+ */
+ export const decryptAES = (encryptData: Uint8Array): Uint8Array | null => {
+    const cipherParams = CryptoJS.lib.CipherParams.create({
+        ciphertext: uint8ArrayToWordArray(encryptData),
+    });
+    const decrytped = CryptoJS.AES.decrypt(cipherParams, aeskey, aesOption);
+
+    return wordArrayToUint8Array(decrytped);
+};