I am having some issues getting myself logged in to a service, which I believe is due to something I´m not doing right with the signing. See the result that I´m getting with the below:
The following is an attempt to do the same, but the result is not the same. Any idea what I´m doing wrong?
B4X:
# echo "test" | openssl dgst -sha256 -hmac "72d4b1c24f2344f29cab98607d41c2a5"
SHA2-256(stdin)= 0e804c9b90d393e8b907bf7ed7cfa6ca53db6fc7c2e0235418e697a7edb25716
The following is an attempt to do the same, but the result is not the same. Any idea what I´m doing wrong?
B4X:
Dim bc As ByteConverter
Dim m As Mac
Dim k As KeyGenerator
Dim Secret As String = "72d4b1c24f2344f29cab98607d41c2a5"
Dim input As String = "test"
Dim m As Mac
Dim k As KeyGenerator
Dim signature As String
k.Initialize("HMACSHA256")
k.KeyFromBytes(Secret.GetBytes("UTF8"))
m.Initialise("HMACSHA256", k.Key)
m.Update(input.GetBytes("UTF8"))
Dim b() As Byte
b = m.Sign
Dim bc As ByteConverter
signature=bc.HexFromBytes(b)
signature = signature.ToLowerCase
Log (signature)
Result:
2d869c0f5bac1f3cecb35c0a1fb85fec4b6d43b27a36d7837d173b09b3916ac2
Last edited: