Skip to content

Instantly share code, notes, and snippets.

Created December 16, 2015 20:14
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 anonymous/1df3c3b39c0d86f7b278 to your computer and use it in GitHub Desktop.
Save anonymous/1df3c3b39c0d86f7b278 to your computer and use it in GitHub Desktop.
TryCF Gist
<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