-
-
Save mmalone/153e9c1872cd2927ca66 to your computer and use it in GitHub Desktop.
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
var ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'; | |
random_base64 = function random_base64(length) { | |
var str = ""; | |
for (var i=0; i < length; ++i) { | |
var rand = Math.floor(Math.random() * ALPHABET.length); | |
str += ALPHABET.substring(rand, rand+1); | |
} | |
return str; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
substring быстрее чем обращение по индексу?