Skip to content

Instantly share code, notes, and snippets.

@BlaM
Last active July 12, 2019 14:41
Show Gist options
  • Save BlaM/f5728b2c1af1b37ebf90c8b87bc579d0 to your computer and use it in GitHub Desktop.
Save BlaM/f5728b2c1af1b37ebf90c8b87bc579d0 to your computer and use it in GitHub Desktop.
Generate 32 character random hex key
function randomKey() {
var r='', l=0;
do {
r += Math.random().toString(16).replace(/[01]\./g, '');
} while (r.length < 32 && l++ < 32);
return r.substr(-32, 32);
};
function randomKey() {
var r='', l=0;
do {
r += Math.random().toString(36).replace(/[01]\./g, '');
} while (r.length < 32 && l++ < 32);
return r.substr(-32, 32);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment