Created
June 14, 2021 17:56
-
-
Save trycf/9b7164a5ed63fadd589cc4ecc5df5d5f 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> | |
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