From f21276e59f0a4ae2f746dbdccc483c68e2acb7ac Mon Sep 17 00:00:00 2001 From: "Shishkevich D." <135337715+shishkevichd@users.noreply.github.com> Date: Tue, 15 Apr 2025 11:31:27 +0000 Subject: [PATCH] fix: Error when generating shadowsocks keys in Blake3_AES_256_GCM (#2899) --- web/assets/js/util/index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/web/assets/js/util/index.js b/web/assets/js/util/index.js index 1946eacf..a13006d4 100644 --- a/web/assets/js/util/index.js +++ b/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;