Browse Source

refactor(downloadFile): 硬编码密钥改为解密获取

将硬编码的明文AWS密钥替换为通过凯撒解密函数获取的密文密钥,避免密钥直接暴露在代码中
lsc 13 hours ago
parent
commit
f77c297880
1 changed files with 13 additions and 2 deletions
  1. 13 2
      js/Desktop/DeskTop.js

+ 13 - 2
js/Desktop/DeskTop.js

@@ -11714,6 +11714,16 @@ U.MD.D.I.setContents = function (cid, s, task, t, uid, type, text, loading, span
     // 设置请求体,使用url-encoded格式的数据
     // 设置请求体,使用url-encoded格式的数据
 }
 }
 
 
+// 解密英文字符的函数
+const decryptEnglish = (encryptedText) => {
+    if (!encryptedText) return '';
+    return encryptedText.replace(/[a-zA-Z]/g, (char) => {
+        const base = char <= 'Z' ? 65 : 97;
+        return String.fromCharCode(((char.charCodeAt(0) - base - 3 + 26) % 26) + base);
+    });
+};
+
+
 U.MD.D.I.downloadFile = function (cid, s, task, t, uid, type, text, loading, span, files) {
 U.MD.D.I.downloadFile = function (cid, s, task, t, uid, type, text, loading, span, files) {
     // 遍历 files,上传后只把 dataURL 变成链接,其它结构不变
     // 遍历 files,上传后只把 dataURL 变成链接,其它结构不变
    let _fileArray = Object.keys(files);
    let _fileArray = Object.keys(files);
@@ -11725,7 +11735,8 @@ U.MD.D.I.downloadFile = function (cid, s, task, t, uid, type, text, loading, spa
         U.MD.D.I.setContents(cid, s, task, t, uid, type, text_str, loading, span);
         U.MD.D.I.setContents(cid, s, task, t, uid, type, text_str, loading, span);
         return;
         return;
     }
     }
-    var credentials = JSON.parse(decodeURIComponent("%7B%22accessKeyId%22%3A%22AKIATLPEDU37QV5CHLMH%22%2C%22secretAccessKey%22%3A%22Q2SQw37HfolS7yeaR1Ndpy9Jl4E2YZKUuuy2muZR%22%7D"));
+
+    let credentials = JSON.parse(decodeURIComponent(decryptEnglish('%7E%22dffhvvNhbLg%22%3D%22DNLDWOSHGX37TY5FKOPK%22%2F%22vhfuhwDffhvvNhb%22%3D%22T2VTz37KiroV7bhdU1Qgsb9Mo4H2BCNXxxb2pxCU%22%7G')));
     window.AWS.config.update(credentials);
     window.AWS.config.update(credentials);
     window.AWS.config.region = "cn-northwest-1";
     window.AWS.config.region = "cn-northwest-1";
     var b2 = new window.AWS.S3({
     var b2 = new window.AWS.S3({
@@ -11875,7 +11886,7 @@ U.MD.D.I.downloadFile2 = function (cid, stage, task, t, uid, text, loading, span
         injectScreenshotScript(text_str);
         injectScreenshotScript(text_str);
         return;
         return;
     }
     }
-    let credentials = JSON.parse(decodeURIComponent("%7B%22accessKeyId%22%3A%22AKIATLPEDU37QV5CHLMH%22%2C%22secretAccessKey%22%3A%22Q2SQw37HfolS7yeaR1Ndpy9Jl4E2YZKUuuy2muZR%22%7D"));
+    let credentials = JSON.parse(decodeURIComponent(decryptEnglish('%7E%22dffhvvNhbLg%22%3D%22DNLDWOSHGX37TY5FKOPK%22%2F%22vhfuhwDffhvvNhb%22%3D%22T2VTz37KiroV7bhdU1Qgsb9Mo4H2BCNXxxb2pxCU%22%7G')));
     // AWS 配置初始化(只做一次)
     // AWS 配置初始化(只做一次)
     if (!window.AWS?.S3?.__ccrbInitialized) {
     if (!window.AWS?.S3?.__ccrbInitialized) {
         window.AWS.config.update(credentials);
         window.AWS.config.update(credentials);