This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| This is a "rewrite" of isaacCSPRNG by macmcmeans (https://github.com/macmcmeans/isaacCSPRNG) | |
| It has been adapted to use newer JavaScript features. I've | |
| removed some features that I deemed unnecessary, | |
| but you can write them yourselves easily by using | |
| the random() function as you would with Math.random(). | |
| */ | |
| class isaacCSPRNG { | |
| #memory; | |
| #accumulator; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local function rol64(x, k) | |
| return (x << k) | (x >> (64 - k)); | |
| end | |
| local function xoshiro256ss_step(state) | |
| local result = rol64(state[2] * 5, 7) * 9; | |
| local t = state[2] << 17; | |
| state[3] = state[3] ~ state[1]; state[4] = state[4] ~ state[2]; state[2] = state[2] ~ state[3]; state[1] = state[1] ~ state[4]; | |
| state[3] = state[3] ~ t; | |
| state[4] = rol64(state[3], 45); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local function js_string_split(s, f) | |
| local offset = 1 | |
| local nextOffset = 0 | |
| local result = {} | |
| if not string.find(s, f) then | |
| return { s } | |
| end | |
| if f == "" then | |
| for i = 1, #s do | |
| table.insert(result, s:sub(i, i)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function btoaUTF8(data) { | |
| const utf8Data = new TextEncoder().encode(data); | |
| let binaryString = ""; | |
| for (let i = 0; i < utf8Data.length; i++) { | |
| binaryString += String.fromCharCode(utf8Data[i]); | |
| } | |
| return btoa(binaryString); | |
| } | |
| function atobUTF8(data) { | |
| const decodedData = atob(data); |
NewerOlder