Created
September 12, 2018 11:46
-
-
Save garenyondem/16e851322d4487dc9bea80b92cfc682b to your computer and use it in GitHub Desktop.
Create random strings for one time usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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