Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
633 views
in Technique[技术] by (71.8m points)

hash - Encoding issues trying to convert hash_hmac

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

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

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...