Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

question from:https://stackoverflow.com/questions/65892201/encoding-issues-trying-to-convert-hash-hmac

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
663 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...