Coldfusion HMAC-SHA1 encryption

拈花ヽ惹草 提交于 2019-12-04 10:07:45
<cfset x1 = toString(tobase64(result))>

The other function is returning hex, not base64. Other than that it seems to work fine for me:

 <cfset x1 = binaryEncode(result, "hex")>

The clue is in your expected output string: it contains only digits and lowercase letters. If you look closer, all the letters are in the range a-f. Therefore it is extremely likely that it is a hexadecimal string.

The last line of your example code encodes the result as base64, not hexadecimal. You can encode the result as hexadecimal by changing the last line to this:

<cfset x1 = binaryEncode(result,"hex")>

I ran the modified code and got

9E734661C9E8B6DC9B6B4B3DEF9769C00E8843B8

which is the uppercase version of your expected string.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!