Skip to content

Instantly share code, notes, and snippets.

@prcaen
Created December 20, 2011 11:00
Show Gist options
  • Save prcaen/1501206 to your computer and use it in GitHub Desktop.
Save prcaen/1501206 to your computer and use it in GitHub Desktop.
[JS] - generateRandomKey
function generateRandomKey(size)
{
var keyset = 'abcdefghijklmnopqrstuvwxyz0123456789';
var randomKey = '';
for (var i = 0; i < size; i++)
{
var rnum = Math.floor(Math.random() * keyset.length);
randomKey += keyset.substring(rnum,rnum + 1);
}
return randomKey;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment