Effacer les filtres
Effacer les filtres

Two files with equal contents but with different SHA256 digest

4 vues (au cours des 30 derniers jours)
RMT
RMT le 3 Jan 2021
Commenté : RMT le 3 Jan 2021
Hello,
I read rgb 'tif' image and splitted it into r, g, b components then reconstructed it back. And to confirm that the tif image has a lossless compression scheme; i compared the two images using different tools (MSE, PSNR, and find) and the two files are 100% matching as expected.
I calculated the SHA256 digest using Hashing_Function for the two files but unfortunately the digests are not equal. And to confirm that the problem is not with the "DataHash" function that i'm using to calculate the SHA256 digest, I double-checked through the attached website SHA256_Tool which gave the exact digests as my test code.
///////////////////////////////////////////////////////////////////////
Below is the output of the test code:
MSE: 0.0; SNR: Inf; PSNR: Inf
The digital signature is not matching
/////////////////////////////////////////////////////////////////////////
I've attached the Original_Image, TestCode, and DataHash file
What is the explanation? and thanks
/////////////////////////////////////////////////////////////////////////
I was investigating the above mentioned issue and i found that when i calculate the digests for the contents of the the two images, then the digests are equal. But the digests are not equal only in the case of using the image as a file.
So i'm still looking for an exact answer about the file case and thanks again

Réponse acceptée

Jan
Jan le 3 Jan 2021
Modifié(e) : Jan le 3 Jan 2021
The TIF files do not even have the same file sizes. How could you expect, that they are bit-wise identical then, which is required for an equal hash?
Although the contained data are equal, the meta data included in the file header are not. There is also an infinite number of different lossless compressions and the applied method does not necessarily create the same byte stream.
Comments of the original image:
Copyright The MathWorks, Inc.
PhotometricInterpretation: 2
PlanarConfiguration: 1
SamplesPerPixel: 3
Comments of the reconstructed image:
PhotometricInterpretation: 2
PlanarConfiguration: 1
SamplesPerPixel: 3
By the way, remember to attach the license file, if you publish a file from the file exchange. The files are published under the BSD license and removing the license information is not a fair use. To consider future changes and bugfixes, prefer to post links to the FileExchange submissions instead of copies. Thanks.
  3 commentaires
RMT
RMT le 3 Jan 2021
I've just added the license file.
Thanks for reminding me and thanks for your answer.
RMT
RMT le 3 Jan 2021
First of all, this DataHash file is yours and thanks for sharing that on FilesExchange.
In the second place, I've just modified my question to include a link to the FileExchange submissions as recommended. So did i reference it correctly? or there is a more common place for refrencing the FileExchange submissions?
Thanks

Connectez-vous pour commenter.

Plus de réponses (1)

Walter Roberson
Walter Roberson le 3 Jan 2021
Modifié(e) : Walter Roberson le 3 Jan 2021
You have not taken into account that the metadata headers in the tif file can be different, including possibilities such as the same metadata contents but different internal order. Or even something a simple as a different creation date being written.
  1 commentaire
RMT
RMT le 3 Jan 2021
Thanks for your answer. Appreciated. And i usually look for your answer in the Matlab community because they are valuable. But the reason i chose to accept Jan's answer is that he mentioned something specific about the file sizes that i've missed in the first place (although intitutive but it just didn't come to my mind to check that when i had those different results).
Thanks

Connectez-vous pour commenter.

Catégories

En savoir plus sur Image Data Workflows dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by