Skip to content

Instantly share code, notes, and snippets.

@garenyondem
Created September 12, 2018 11:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garenyondem/16e851322d4487dc9bea80b92cfc682b to your computer and use it in GitHub Desktop.
Save garenyondem/16e851322d4487dc9bea80b92cfc682b to your computer and use it in GitHub Desktop.
Create random strings for one time usage
function nonce(length) {
var text = '';
var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for (var i = 0; i < length; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
}
module.exports = nonce;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment