Archived Forum Post

Index of archived forum posts

Question:

Generate MAC

Oct 24 '12 at 07:05

Hi,

I need to be able to calculate the MAC for a specific text string using SHA256. Since I am new to this I am a bit lost.

Below is what I have done so far to specify the algorithm and set the key. How do I specify the string to run through the algorithm?

obj.SetHmacKeyString("mykey") obj.HashAlgorithm = "sha256"

Cheers, Marcus


Answer

I got it (VB.Net)!

    Dim obj As New Chilkat.Crypt2()
    Dim strMAC As String

    obj.UnlockComponent("Hello World")
    obj.SetHmacKeyEncoded(My.Resources.config.key, "hex")
    obj.HashAlgorithm = "sha256"
    obj.EncodingMode = "hex"
    strMAC = obj.HmacStringENC("00000000")