Last active
August 29, 2015 13:59
-
-
Save lovio/10848206 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
function generateRandomAlphaNum(len) { | |
var rdmString = ""; | |
for (; rdmString.length < len; rdmString += Math.random().toString(36).substr(2)); | |
return rdmString.substr(0, len); | |
}; |
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 get_scramble_code (num){ | |
return _.sample("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", num).join(''); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
第一种方法很聪明,利用36进制。。。