Encoding issues trying to convert hash_hmac

Viewed 36

I am trying to convert the following code to ColdFusion. This is what I have tried so far but I am unable to get the exact results.

The code I have this:

$path = '/0/Balance';
$results = base64_encode(hash_hmac('sha512', $path . hash('sha256', ''1611597432061857nonce=1611597432061857, true), base64_decode($this->secret), true));

My ColdFusion code up till now:

<cfset nonce = '1611597432061857nonce=1611597432061857'>

<cfset iHash = lcase(hash(nonce, "SHA-256"))>
<cfset chrEncoded = CharsetEncode(binaryDecode(iHash, "hex" ),'utf-8')>
<cfset string_to_sign = "/0/Balance">

<cfdump var="#string_to_sign#">
    
<cfset api_sign = CharsetEncode(binaryDecode(hmac(string_to_sign & chrEncoded, tobinary(secret_key), "HMACSHA512"),'hex'),'utf-8')>
<br>
<cfdump var="#api_sign#" abort>

I am using Adobe ColdFusion 2016. What am I doing wrong?

0 Answers
Related