diff options
| author | Shishkevich D. <135337715+shishkevichd@users.noreply.github.com> | 2025-03-09 15:37:53 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-09 15:37:53 +0300 |
| commit | ad13ce6cde04f989009541fd9ce4bdb0ba5f8646 (patch) | |
| tree | 559d964d9257db12372b037863ce99658ff1891d /web | |
| parent | c35179d9240647884f592622d036bfad228f7bda (diff) | |
fix: generating shortIds for vless reality (#2745)
Diffstat (limited to 'web')
| -rw-r--r-- | web/assets/js/util/index.js | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/web/assets/js/util/index.js b/web/assets/js/util/index.js index 75cf915d..44af6630 100644 --- a/web/assets/js/util/index.js +++ b/web/assets/js/util/index.js @@ -81,11 +81,20 @@ class PromiseUtil { } class RandomUtil { - static getSeq({ hasNumbers = true, hasLowercase = true, hasUppercase = true } = {}) { + static getSeq({ type = "default", hasNumbers = true, hasLowercase = true, hasUppercase = true } = {}) { let seq = ''; - if (hasNumbers) seq += "0123456789"; - if (hasLowercase) seq += "abcdefghijklmnopqrstuvwxyz"; - if (hasUppercase) seq += "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + switch (type) { + case "hex": + seq += "0123456789abcdef"; + break; + default: + if (hasNumbers) seq += "0123456789"; + if (hasLowercase) seq += "abcdefghijklmnopqrstuvwxyz"; + if (hasUppercase) seq += "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + break; + } + return seq; } @@ -107,7 +116,7 @@ class RandomUtil { static randomShortIds() { const lengths = [2, 4, 6, 8, 10, 12, 14, 16].sort(() => Math.random() - 0.5); - return lengths.map(len => this.randomSeq(len)).join(','); + return lengths.map(len => this.randomSeq(len, { type: "hex" })).join(','); } static randomLowerAndNum(len) { |
