Skip to content

Instantly share code, notes, and snippets.

Created December 16, 2015 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/e84899e553af4152b6ce to your computer and use it in GitHub Desktop.
Save anonymous/e84899e553af4152b6ce 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 &= 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