Browse Source

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

huangbin 4 years ago
parent
commit
f72c2674b5
1 changed files with 14 additions and 0 deletions
  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);
     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);
+};