소스 검색

手动增加 dead code

Michael Wang 3 년 전
부모
커밋
b0deab73a3
1개의 변경된 파일24개의 추가작업 그리고 0개의 파일을 삭제
  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()) {