Why do seemingly empty files and strings produce md5sums?

后端 未结 3 1982
伪装坚强ぢ
伪装坚强ぢ 2021-01-31 07:56

Consider the following:

% md5sum /dev/null
d41d8cd98f00b204e9800998ecf8427e  /dev/null
% touch empty; md5sum empty
d41d8cd98f00b204e9800998ecf8427e  empty
% echo         


        
3条回答
  •  梦谈多话
    2021-01-31 08:06

    Why do seemingly empty files and strings produce md5sums?

    Because the "sum" in the md5sum is somewhat misleading. It's not like e.g. CRC32 checksum, that is zero for the empty file.

    MD5 is one of message digest algorithms. You can imagine it as a box that produces fixed-length random-looking value (hash) depending on its internal state. You change the internal state by feeding in the data.

    And that box internal state is predefined, such that that it yields randomly looking hash value even before any data is fed in. For MD5, it happens to be d41d8cd98f00b204e9800998ecf8427e.

提交回复
热议问题