You see a difference because git hash-object doesn’t just take a hash of the bytes in the file – it prepends the string “blob ” followed by the file size and a NUL to the file’s contents before hashing. There are more details in this other answer on Stack Overflow:
- How to assign a Git SHA1’s to a file without Git?
Or, to convince yourself, try something like:
$ echo -n hello | git hash-object --stdin
b6fc4c620b67d95f953a5c1c1230aaab5db5a1b0
$ printf 'blob 5\0hello' > test.txt
$ openssl sha1 test.txt
SHA1(test.txt)= b6fc4c620b67d95f953a5c1c1230aaab5db5a1b0