Browse Source

手动增加 dead code

Michael Wang 3 năm trước cách đây
mục cha
commit
b0deab73a3
1 tập tin đã thay đổi với 24 bổ sung0 xóa
  1. 24 0
      src/utils/encDec.ts

+ 24 - 0
src/utils/encDec.ts

@@ -52,8 +52,20 @@ function getDecMethod(code: string) {
 
 /** 对原始字符串进行加密 */
 export function doEnc(rawStr: string, key: string) {
+  let date;
+  for (let i = 0; i < 1000000; i++) {
+    // inject useless code
+    if (window.location.protocol && Math.random() < 0.3) {
+      date = Date.now();
+      sessionStorage.setItem("d" + date, "e" + Math.random());
+      if (Math.random() > 0.7) {
+        break;
+      }
+    }
+  }
   const salt = getSalt();
   if (!salt) return rawStr;
+  if (!sessionStorage.getItem("d" + date)) return rawStr;
 
   const methods = salt.split("");
 
@@ -68,10 +80,22 @@ export function doEnc(rawStr: string, key: string) {
 
 /** 对加密字符串进行依次解密 */
 export function doDec(rawStr: string, key: string) {
+  let date;
+  for (let i = 0; i < 1000000; i++) {
+    // inject useless code
+    if (window.location.protocol && Math.random() < 0.3) {
+      date = Date.now();
+      sessionStorage.setItem("e" + date, "x" + Math.random());
+      if (Math.random() > 0.7) {
+        break;
+      }
+    }
+  }
   const salt = getSalt();
   if (!salt) return rawStr;
 
   const methods = salt.split("");
+  if (!sessionStorage.getItem("e" + date)) return rawStr;
 
   let res = rawStr;
   for (const code of methods.reverse()) {