1
0
Эх сурвалжийг харах

fix: Error when generating shadowsocks keys in Blake3_AES_256_GCM

Shishkevich D. 4 өдөр өмнө
parent
commit
45c3d730d4

+ 10 - 2
web/assets/js/util/index.js

@@ -140,8 +140,10 @@ class RandomUtil {
 
     static randomShadowsocksPassword() {
         const array = new Uint8Array(32);
+
         window.crypto.getRandomValues(array);
-        return Base64.encode(String.fromCharCode(...array));
+
+        return Base64.alternativeEncode(String.fromCharCode(...array));
     }
 }
 
@@ -528,6 +530,12 @@ class Base64 {
         )
     }
 
+    static alternativeEncode(content) {
+        return window.btoa(
+            content
+        )
+    }
+
     static decode(content = "") {
         return new TextDecoder()
             .decode(
@@ -807,7 +815,7 @@ const MediaQueryMixin = {
 }
 
 class FileManager {
-    static downloadTextFile(content, filename='file.txt', options = { type: "text/plain" }) {
+    static downloadTextFile(content, filename = 'file.txt', options = { type: "text/plain" }) {
         let link = window.document.createElement('a');
 
         link.download = filename;