Created
January 28, 2022 17:06
-
-
Save hayleyxyz/f547f9ab6fd6644775779bbf9df3fa39 to your computer and use it in GitHub Desktop.
some other dumb random string generator i made.js
This file contains 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
const rnd = (len) => { | |
const arr = new Uint8Array(len); | |
crypto.getRandomValues(arr) | |
let str = ''; | |
for(i in arr) { | |
start = 33; | |
end = 126; | |
str += String.fromCharCode((arr[i] % (end - start)) + start) | |
} | |
return str; | |
}; | |
console.log(rnd(256)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment