hashlib
hashlib copied to clipboard
How do you hash a file using hashlib's xxhash?
I am trying to use xxHash3 128 bits for hashing a file, I am using readFile but I am getting an incorrect checksum.
I also tried using streams with openFileStream and I am getting the same wrong checksum.
Any ideas?
Here is what I am using:
...
import hashlib/misc/xxhash
proc verify*(file: string, checksum: string): bool =
checksum == $count[XXHASH3_128](readFile(file))
...
Where file is a .tar.gz tarball (I'll be using make-4.4.tar.gz as an example.
I am using xxh128sum to get the expected checksum 15bf27bd70e74eb8c4f71a1028513adf, but the function above is returning a wrong checksum of faae50855f65ad63b1c4c71c19166a3c.
How can I fix this?
Any updates to this?