views:

133

answers:

1

Why on the same machine computing the SHA-1 hash of the same file produces two completely different SHA-1 hashes in windows and inside a msysgit Git bash?

Doesn't the SHA-1 algorithm was intended to produce the same hash for the same file in all OSes?

On windows (with HashCheck): File hello.txt 22596363b3de40b06f981fb85d82312e8c0ed511

Inside a msysgit's Git bash windows (same machine, same file):

$ git hash-object hello.txt 3b18e512dba79e4c8300dd08aeb37f8e728b8dad

+6  A: 

Git adds a header ("blob ", the length, then null) before calculating the SHA-1. See this blog post for how to emulate the calculation outside git.

Matthew Flaschen
Thank you very much Matthew! The fun story is that yesterday I received my copy of Pro Git from Amazon ;-)I started to read it online exactly the moment after having read your answer here: aka NOW!
Fabio Vitale