Created
December 16, 2015 20:14
-
-
Save anonymous/1df3c3b39c0d86f7b278 to your computer and use it in GitHub Desktop.
TryCF Gist
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
<cfscript> | |
function genToken(numeric numOfbytes=32) | |
{ | |
var hex = ""; | |
for (var byte = 0; byte < numOfbytes; byte++) | |
{ | |
var randomByte = RandRange(0, 255, 'SHA1PRNG'); | |
var randomHex = FormatBaseN(randomByte,16); | |
hex &= len(randomHex) == 1 ? 0 & randomHex : randomHex; | |
} | |
var binary = binaryDecode(hex, 'hex'); | |
var base64 = toBase64(binary); | |
var base64url = replaceList(base64, "+,/,=", "-,_,"); | |
return base64url; | |
} | |
for ( i = 1 ; i <= 25 ; i++) | |
writeOutput("#i#: " & genToken() & "<br>"); | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment