I'm trying to create a signature to our bank from a specified key but my results is not the same as the info I got from the bank. Can anyone see what I am doing wrong?
Link to bank for reference (text in Swedish)
Example data are inside the citationmarks .. :)
Filedata: "00000000"
Key: "1234567890ABCDEF1234567890ABCDEF"
Expected result: "FF365893D899291C3BF505FB3175E880"
My result: "05CD81829E26F44089FD91A9CFBC75DB"
My code:
// Using ASCII teckentabell
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
// Using HMAC-SHA256
byte[] keyByte = encoding.GetBytes("1234567890ABCDEF1234567890ABCDEF");
HMACSHA256 hmacsha256 = new HMACSHA256(keyByte);
byte[] messageBytes = encoding.GetBytes("00000000");
byte[] hashmessage = hmacsha256.ComputeHash(messageBytes);
byte[] truncArray = new byte[16];
Array.Copy(hashmessage, truncArray, truncArray.Length);
// conversion of byte to string
string sigill = ByteArrayToString(truncArray);
// show sigill
MessageBox.Show("Sigill:\n" + sigill, "Sigill", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);