From ad13ce6cde04f989009541fd9ce4bdb0ba5f8646 Mon Sep 17 00:00:00 2001
From: "Shishkevich D." <135337715+shishkevichd@users.noreply.github.com>
Date: Sun, 9 Mar 2025 19:37:53 +0700
Subject: [PATCH] fix: generating shortIds for vless reality (#2745)

---
 web/assets/js/util/index.js | 19 ++++++++++++++-----
 1 file 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) {