From 64fa0e97a30eb8f21b37f358b6382abcb4e4d9f2 Mon Sep 17 00:00:00 2001 From: "Shishkevich D." <135337715+shishkevichd@users.noreply.github.com> Date: Sun, 9 Mar 2025 06:09:42 +0000 Subject: [PATCH] chore: use `crypto.randomUUID()` for generating UUIDv4 --- web/assets/js/util/index.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/web/assets/js/util/index.js b/web/assets/js/util/index.js index cecc8dd4..0fea0592 100644 --- a/web/assets/js/util/index.js +++ b/web/assets/js/util/index.js @@ -126,14 +126,7 @@ class RandomUtil { } static randomUUID() { - const template = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'; - return template.replace(/[xy]/g, function (c) { - const randomValues = new Uint8Array(1); - crypto.getRandomValues(randomValues); - let randomValue = randomValues[0] % 16; - let calculatedValue = (c === 'x') ? randomValue : (randomValue & 0x3 | 0x8); - return calculatedValue.toString(16); - }); + return window.crypto.randomUUID() } static randomShadowsocksPassword() {