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.

Revisions

  1. makotoworld created this gist Jan 16, 2013.
    15 changes: 15 additions & 0 deletions random_key.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    //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