Created
February 19, 2014 08:13
-
-
Save Noitidart/9087938 to your computer and use it in GitHub Desktop.
OAuth nonce generator function from codebird, its bascially a random string generator.
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
//https://github.com/jublonet/codebird-js/blob/master/codebird.js#L745 | |
function _nonce(length) { | |
if (typeof length === "undefined") { | |
length = 8; | |
} | |
if (length < 1) { | |
console.warn("Invalid nonce length."); | |
} | |
var nonce = ""; | |
for (var i = 0; i < length; i++) { | |
var character = Math.floor(Math.random() * 61); | |
nonce += "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz".substring(character, character + 1); | |
} | |
return nonce; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment