Skip to content

Instantly share code, notes, and snippets.

@makotoworld
Created January 16, 2013 06:33
Show Gist options
  • Save makotoworld/4545099 to your computer and use it in GitHub Desktop.
Save makotoworld/4545099 to your computer and use it in GitHub Desktop.
//JSでランダムなキーをつくる
var randobet = function(n, b) {
b = b || '';
var a = 'abcdefghijklmnopqrstuvwxyz'
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+ '0123456789'
+ b;
a = a.split('');
var s = '';
for (var i = 0; i < n; i++) {
s += a[Math.floor(Math.random() * a.length)];
}
return s;
};
// randobet(10, '-_!'); // 2OM_g0-76n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment