2016-09-21 116 views
0

VB.net代码:PHP hash_hmac无法获得相同的结果vb.net结果HMACSHA

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 

PHP的:

$ha1='RHBNow'; 

$ha2=7090982.885183; 

$binarySignature = base64_encode(hash_hmac('sha1',$ha1,$ha2, true)); 

$urlSafeSignature = urlencode($binarySignature); 

结果:

PS7%2FPqt95CtEEGeNsNOV1y%2FEaQ4%3D 

无法获得与vb.net结果相同的结果。

回答

0

,请尝试以下方法:

<?php 
$ha1 = "RHBNow"; 
$ha2 = "7090982.885183"; 
echo $hash = hash_hmac('sha1', $ha2, $ha1); 
?> 

感谢。