We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1893c38 commit a811225Copy full SHA for a811225
web/assets/js/util/index.js
@@ -124,7 +124,18 @@ class RandomUtil {
124
}
125
126
static randomUUID() {
127
- return window.crypto.randomUUID();
+ if (window.location.protocol === "https:") {
128
+ return window.crypto.randomUUID();
129
+ } else {
130
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
131
+ .replace(/[xy]/g, function (c) {
132
+ const randomValues = new Uint8Array(1);
133
+ window.crypto.getRandomValues(randomValues);
134
+ let randomValue = randomValues[0] % 16;
135
+ let calculatedValue = (c === 'x') ? randomValue : (randomValue & 0x3 | 0x8);
136
+ return calculatedValue.toString(16);
137
+ });
138
+ }
139
140
141
static randomShadowsocksPassword() {
0 commit comments