Last active
July 26, 2016 01:22
-
-
Save rndme/11beca97415dd720cc51dfd3a121fc6b to your computer and use it in GitHub Desktop.
a fast clock times a slow clock and uses a factor of the difference to build a un-predictable 36 alphabet string
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
function nonce(chars){ | |
var b="", round, last; | |
while(true){ | |
var round= (Date.now() / (performance.now()*1000)).toString(36).split(".").pop().slice(2, -2); | |
if(round!=last) b+= round; | |
if(b.length > chars) break; | |
last=round; | |
} | |
return b.slice(-chars); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment