Skip to content

Instantly share code, notes, and snippets.

@lovio
Last active August 29, 2015 13:59
Show Gist options
  • Save lovio/10848206 to your computer and use it in GitHub Desktop.
Save lovio/10848206 to your computer and use it in GitHub Desktop.
生成随机字符串
function generateRandomAlphaNum(len) {
var rdmString = "";
for (; rdmString.length < len; rdmString += Math.random().toString(36).substr(2));
return rdmString.substr(0, len);
};
function get_scramble_code (num){
return _.sample("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", num).join('');
}
@lovio
Copy link
Author

lovio commented Apr 16, 2014

第一种方法很聪明,利用36进制。。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment