How can I set the HMACSHA1 key to hex?


R

RedEye

I have tested the output against a hash calculation application. Every thing
works fine but the only problem is that in order for the hash to match the
ap's hash the HMACSHA1.Key needs to be set to HEX. Is there a different
encoding type I should be using?

Any help would be appreciated.

Below is the code in it's current form.

Public Function CalculateHMAC(ByVal data As String, ByVal key As String) As
String
Dim bData As Byte() = Encoding.UTF8.GetBytes(data)
Dim bKey As Byte() = Encoding.UTF8.GetBytes(key)
Dim hmac As HMACSHA1 = New HMACSHA1(bKey)

Using cryptoStream As CryptoStream = New CryptoStream(Stream.Null, hmac,
CryptoStreamMode.Write)
cryptoStream.Write(bData, 0, bData.Length)
End Using

Return HexEncoding.ToString(hmac.Hash)
End Function


Thanks!!
 
Ad

Advertisements

R

RedEye

I got it to work...

It always seem to work out after you post it to the group.

Thanks!
 
Ad

Advertisements

Joined
Feb 25, 2011
Messages
1
Reaction score
0
Hi RedEye,

I'm new in vb and trying to encrypt a file converted to hex with a hex key.How did you get your program to work?

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top