fix #3622
Some checks failed
Release 3X-UI / build (386) (push) Has been cancelled
Release 3X-UI / build (amd64) (push) Has been cancelled
Release 3X-UI / build (arm64) (push) Has been cancelled
Release 3X-UI / build (armv5) (push) Has been cancelled
Release 3X-UI / build (armv6) (push) Has been cancelled
Release 3X-UI / build (armv7) (push) Has been cancelled
Release 3X-UI / build (s390x) (push) Has been cancelled
Release 3X-UI / Build for Windows (push) Has been cancelled

This commit is contained in:
MHSanaei 2026-01-03 22:31:31 +01:00
parent a6b3623634
commit 3f15d21f13
No known key found for this signature in database
GPG key ID: 7E4060F2FBE5AB7A

View file

@ -142,7 +142,7 @@ class RandomUtil {
let length = 32; let length = 32;
if ([SSMethods.BLAKE3_AES_128_GCM].includes(method)) { if ([SSMethods.BLAKE3_AES_128_GCM].includes(method)) {
length = 16; length = 16;
} }
const array = new Uint8Array(length); const array = new Uint8Array(length);
@ -154,28 +154,28 @@ class RandomUtil {
static randomBase32String(length = 16) { static randomBase32String(length = 16) {
const array = new Uint8Array(length); const array = new Uint8Array(length);
window.crypto.getRandomValues(array); window.crypto.getRandomValues(array);
const base32Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'; const base32Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
let result = ''; let result = '';
let bits = 0; let bits = 0;
let buffer = 0; let buffer = 0;
for (let i = 0; i < array.length; i++) { for (let i = 0; i < array.length; i++) {
buffer = (buffer << 8) | array[i]; buffer = (buffer << 8) | array[i];
bits += 8; bits += 8;
while (bits >= 5) { while (bits >= 5) {
bits -= 5; bits -= 5;
result += base32Chars[(buffer >>> bits) & 0x1F]; result += base32Chars[(buffer >>> bits) & 0x1F];
} }
} }
if (bits > 0) { if (bits > 0) {
result += base32Chars[(buffer << (5 - bits)) & 0x1F]; result += base32Chars[(buffer << (5 - bits)) & 0x1F];
} }
return result; return result;
} }
} }
@ -908,7 +908,10 @@ class IntlUtil {
const language = LanguageManager.getLanguage() const language = LanguageManager.getLanguage()
const now = new Date() const now = new Date()
const diff = Math.round((date - now) / (1000 * 60 * 60 * 24)) // Handle delayed start (negative expiryTime values)
const diff = date < 0
? Math.round(date / (1000 * 60 * 60 * 24))
: Math.round((date - now) / (1000 * 60 * 60 * 24))
const formatter = new Intl.RelativeTimeFormat(language, { numeric: 'auto' }) const formatter = new Intl.RelativeTimeFormat(language, { numeric: 'auto' })
return formatter.format(diff, 'day'); return formatter.format(diff, 'day');