Created
February 7, 2016 13:30
-
-
Save amfg/e007f5ee0e3d2d981897 to your computer and use it in GitHub Desktop.
Generate random unicode 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
random = function(length) { | |
var array = new Uint16Array(length); | |
window.crypto.getRandomValues(array); | |
var str = ''; | |
for (var i = 0; i < array.length; i++) { | |
str += String.fromCharCode(array[i]); | |
}; | |
return str; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What about