Last active
July 26, 2016 07:55
-
-
Save rndme/7fb78880ba3a2297bef746283c82ab46 to your computer and use it in GitHub Desktop.
given a seed value "iv" (optional), returns a deterministic string of pseudo-random hex values of length "chars"
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 stream(chars, iv){ // requires https://github.com/emn178/js-sha3/ | |
var buff="", i=0; | |
iv= sha3_512(iv || (Date.now() / (performance.now()*1000)).toString(36) + (chars/Math.random())); | |
while(buff.length < chars) buff+= iv = sha3_256(++i + iv); | |
return buff.slice(0, chars); | |
} | |
//ex: | |
// stream(500, "this is not a great iv"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment