Skip to content

Commit f50dcbb

Browse files
Recenter uid clone around cryptographic numbers
I find the syntax a bit nicer.
1 parent fce0275 commit f50dcbb

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

static/extensions/steve0greatness/timers.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @overview
33
*
4-
* Defines the "Extra Timers" extension for PenguinMod.
4+
* Allows for the creation and management of additional timers in PenguinMod.
55
*
66
* @license MIT
77
* @author Steve0Greatness
@@ -16,11 +16,12 @@ const selfid = "steve0greatnesstimers";
1616
function uid_clone() {
1717
const soup = "!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
1818
const length = 20;
19+
20+
const max = num => (num & 127) >= soup.length ? (num & 127) - soup.length : (num & 127);
1921

20-
return Array.from(
21-
{ length },
22-
_ => soup.charAt(Math.random() * soup.length)
23-
).join("");
22+
return [...crypto.getRandomValues(new Uint8Array(length))]
23+
.map((e) => soup.charAt(max(e)))
24+
.join("");
2425
}
2526

2627
function xml_escape(unsafe) {

0 commit comments

Comments
 (0)