How to zero byte files generate a hash value

hashingsha1

How can a zero byte text file generate a hash when hashed with sha1sum, sha256sum etc? What data are the programs hashing to generate a hash value?

Ta

QuickHash in Linux

Terminal Commands

Best Answer

Hash algorithms read the input and process it, no matter if there's data at all. This is a valid and wanted behaviour and is even used to verify if a certain implementation is correct. This leads to "null-hashes" for all major algorithms.

To sum it up: da39a3ee5e6b4b0d3255bfef95601890afd80709 is the sha1-hash for an empty file everywhere, the same is true with the null-hashes of other alrogrithms.