Skip to content

Instantly share code, notes, and snippets.

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 trycf/9b7164a5ed63fadd589cc4ecc5df5d5f to your computer and use it in GitHub Desktop.
Save trycf/9b7164a5ed63fadd589cc4ecc5df5d5f to your computer and use it in GitHub Desktop.
TryCF Gist
<cfscript>
apiKey = "yourApiKey";
apiSecret = "youApiSecret";
// Also try binaryDecode() instead charsetDecode
// if secret is a base64 encoded string
theKeyBytes = charsetDecode(apiSecret, "UTF-8");
//timeStamp = "1623692403";
timeStamp = int( now().getTime() / 1000 );
method = "GET";
requestPath = "/v2/prices/spot?currency=USD";
theBody = "";
message = timeStamp & method & requestPath & theBody;
signatureHex = hmac( message, theKeyBytes, "HMACSHA256");
signatureBase64 = binaryEncode( binaryDecode( signatureHex, "hex"), "base64" );
writeOutput( "<br>"& signatureHex);
writeOutput( "<br>"& signatureBase64);
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment