VB.net代码:
Function HMACSHA(ByVal Key As String, ByVal Value As String)
Dim objHMAC As New HMACSHA1(Encoding.ASCII.GetBytes(Key))
HMACSHA_Encrypt = (objHMAC.ComputeHash(Encoding.ASCII.GetBytes(Value)))
End Function
实施例
Key e.g. “RHBNow”
Value e.g. “7090982.885183” based on custom hash algorithms
Hash value e.g. bcf370bcbb6248c4d718ec17e5c6982477744f6a
腓:
$ha1='RHBNow';
$ha2=7090982.885183;
$binarySignature = base64_encode(hash_hmac('sha1',$ha1,$ha2, true));
$urlSafeSignature = urlencode($binarySignature);
结果:
PS7%2FPqt95CtEEGeNsNOV1y%2FEaQ4%3D
无法获得与vb.net结果相同的结果。
答案 0 :(得分:0)
请尝试以下方法:
<?php
$ha1 = "RHBNow";
$ha2 = "7090982.885183";
echo $hash = hash_hmac('sha1', $ha2, $ha1);
?>
感谢。