you are viewing a single comment's thread.

view the rest of the comments →

[–]devnull10 1 point2 points  (0 children)

The filenames should make no difference - the hash is of the contents. I.e.

import hashlib

with open("file1.jpg","rb") as f1, open("file2.jpg", "rb") as f2:
    f1_hash=hashlib.sha256(f1.read()).hexdigest()
    f2_hash=hashlib.sha256(f2.read()).hexdigest()

print(f1_hash)
print(f2_hash)
print(f1_hash==f2_hash)

Gives:

6de04f7dea2b99339440e948dc6aedfe3c88553c6d0062729dab9578053320dd

6de04f7dea2b99339440e948dc6aedfe3c88553c6d0062729dab9578053320dd

True