I'm learning about SHA1 (specifically wrt Git), and I wanted to sanity-check my understanding by calculating a string's SHA1 with different methods - I expected identical SHA1 hashes, but instead I got distinct results from three of four methods:
>git hash-object --stdin <<< "Apple Pie" 23991897e13e47ed0adb91a0082c31c82fe0cbe5
>sha1sum <<< "blob 9\0Apple Pie" 332cd56150dc8b954c0b859bd4aa6092beafa00f -
>printf 'blob 9\0Apple Pie' > foo.txt >sha1sum foo.txt 9eed377bbdeb4aa5d14f8df9cd50fed042f41023 foo.txt
>openssl sha1 foo.txt SHA1(foo.txt)= 9eed377bbdeb4aa5d14f8df9cd50fed042f41023
The accepted answer to this Stack Overflow question says that
git hash-object runs a SHA1 hash on the specified content prefixed with "blob [file size]/0". Thus I explicitly prefixed that text to the strings I tested with the non-git method.
Why all these different results? I thought SHA1 was a specific and unique hash of a given string, and that there were not different "types" of SHA1 - is that not true?