Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 7074

How could sha256sum ever give different result for the same file?

$
0
0

In Ubuntu 24.04, sha256sum gave me different results for the same file on multiple occasions. Below is an excerpt of my shell log.

$ for i in *.7z; do sha256sum $i; done...a5a887bd0c9e9ed03a1a7851c2b6216ce77284c5d8fd326c008426475d39c3b8  somefile=.7z...$ pv somefile=.7z  | sha256sum...f62423e10e3a629fe07a5d4d3212942af55541cc1d7b4498a1ca2d97aafdb9c3  -$ sha256sum somefile=.7zf62423e10e3a629fe07a5d4d3212942af55541cc1d7b4498a1ca2d97aafdb9c3  somefile=.7z$ for i in *.7z; do sha256sum $i; done...f62423e10e3a629fe07a5d4d3212942af55541cc1d7b4498a1ca2d97aafdb9c3  somefile=.7z...

The somefile=.7z got one hash during the first loop, but another hash later on. The file is never ever modified since being created long ago. The shell log above was taken with minutes. The file size is about 10G.

I can no longer reproduce the problem since the hash seems to be already stabilized. But before taking the log excerpt above, sha256sum gave me two other different hash, so four in total, which makes it difficult for me to trust the result of sha256sum anymore.

So, my question is, how could such difference ever appear, under any circumstance that I might forget to mention?

Some factors that might matter:

  • the first call of sha256sum was in a loop
  • the file is rather large
  • the filename contains symbol =
  • the file has been copied to an external hard drive that is still mounted

but none of them could justify the difference to my knowledge.


UPDATE

It turns out that the first hash (a5a887...) equals the sha1sum of an old file with same name (somefile=.7z) and same directory. But that old file was replaced long before the first loop. This smells like a bug of caching by filename.


Viewing all articles
Browse latest Browse all 7074

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>