New to the community, but not new to programming.
I’ve been trying to get a collection of hash functions up/running and I succeeded. However I found some weird results and haven’t been able to put my finger on it yet. RFC4634 contains a C implementation for SHA-1 and SHA-2 family, which also can accept a file being passed on for hashing. RFC3174 contains a C implementation, but doesn’t process file streams. I’ve been using the C implementation from RFC4634 to verify files, yet the verification process is returning non similar results when I compare them against SHA-1 provided hashes.
Any idea what the reasons could be?
Did you check if you opened the files in ASCII or binary mode? Line end translation may be performed before the hash is being calculated.
Update:
I just compiled the RFC4634
shatestand tried on a sample text file. As long as there isn’t a line break, all tools agree. Once you insert a line break, results depend: if the text file uses CR and LF (DOS mode), then shatest produces a different result. If the line end is only LF (UNIX), it still agrees with the other tools.Update 2:
In the file
shatest.cof RFC4634, in functionhashfile(...), setfopento binary mode: