本文介绍了ColdFusion相当于PHP hash_hmac的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$key = "12345678876543211234567887654321";
$iv = "1234567887654321";
$plaindata = "This is a test string";
$enc = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $plaindata, MCRYPT_MODE_CBC, $iv));
$str = hash_hmac("sha256", utf8_encode($iv . '.' . $enc), utf8_encode($key));
echo($str);
这给我e63d4ab83f90cfec1acdaf831091b6394167ae728b657e44afad1e7553843eeb
This gives me e63d4ab83f90cfec1acdaf831091b6394167ae728b657e44afad1e7553843eeb
我在ColdFusion9开发版中得到相同的结果?
How can I get the same result in ColdFusion9 Development Edition?
推荐答案
我在这个页面上找到了一个解决方案
I found a solution on this page http://www.isummation.com/blog/calculate-hmac-sha256-digest-using-user-defined-function-in-coldfusion/
您需要像这样调用函数
<cfoutput>#LCase(HMAC_SHA256(iv & "." & Encrypted_Data, key))#</cfoutput>
像一个魅力。
这篇关于ColdFusion相当于PHP hash_hmac的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!