
Originally Posted by
dilettante
That web page sort of sucks.
The "key" value must be entered as printable/typeable text, you can't use a string of hex digits. If you do that it just takes it as text and you get an incorrect HMAC value there.
Here's an example with optional "sucks" mode:
Thank you for you sample dilettante, it works as expected.
here is my code before
Code:
Private Sub Command1_Click()
Dim xKey As String
Dim xData As String
Dim bSig() As Byte
Dim StringToSign() As Byte
Dim secretKey() As Byte
xKey = "a4f6bf89b2a85781b7c1cab997b7ee0c89be03f7ac6ef29b63a45d07253cc401"
xData = "hypermart1468914526"
With hs256
StringToSign = .ToUTF8(xData)
secretKey = .ToUTF8(xKey)
.InitHmac secretKey
Erase secretKey
bSig = .HmacSha256(StringToSign)
Erase StringToSign
MsgBox .Encode(bSig, edfBase64, efNoFolding)
Erase bSig
End With
End Sub
i realize that the msgbox line was the cause why the result always incorrect, after removing edfBase64 and efNoFolding the result was correct