Last active
May 26, 2023 13:13
-
-
Save FlameWolf/135bb4bae8518a45a7f5a2b6344bbbf3 to your computer and use it in GitHub Desktop.
Generate random ID string
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
const getRandomIdString = (len = 32) => { | |
let retVal = ""; | |
for (let i = 0; i < len; i++) { | |
const randVal = Math.random(); | |
retVal += String.fromCharCode((randVal < 0.5 ? ((randVal * 26) + 65) : ((randVal * 10) + 48)) >> 0); | |
} | |
return retVal; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment