2

I have been struggling for 4 days trying to implement a hash algorithm in c# which works like the FIPS 198 standards document. I have reached a point where I have a value of

06070405020300010e0f0c0d0a0b080976777475363636363636363636363636363636363636363636363636363636363636363636363636363636363636363653616d706c65202332

I took this value and inserted it into the binary hash tool on http://www.fileformat.info/tool/hash.htm and the SHA-1 value is what I am expecting, but I can't replicate this in c#.

Expected value:

SHA-1: 74766e5f6913e8cb6f7f108a11298b15010c353a

When I use the SHA1 class in c# I get the value a969fdc725114c8418ca5c23946bd09977054ff6, which is the same as me entering my value above in the String Hash tool.

Could someone please point me in the right direction to generate what I require.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
remeez
  • 38
  • 3
  • [Padding](http://en.wikipedia.org/wiki/Padding_(cryptography)) probably explains this. – Oded Nov 14 '12 at 09:35

1 Answers1

0

You will need to convert your hex-string data into a byte array. There are plenty of examples online of how to do this. One example posted to SO already is here (use the StringToByteArray function). Once you have a byte array, pass this through the SHA-1 hash and you should get the output you require.

Community
  • 1
  • 1
Iridium
  • 23,323
  • 6
  • 52
  • 74