File Hashes from Python

20 July, 2025 - #python

I was looking at using SQLite for a side project, and wanted to verify the file hashes after downloading.

This is on a Windows PC, so normally what I'd do is something like this:

Get-FileHash -Algorithm SHA256 sqlite-dll-win-x64-3500300.zip

However, Get-FileHash does not currently support SHA-3, and sqlite3 downloads are provided with SHA-3-256 hashes.

Normally I also submit downloads to Virus Total for malware scanning, but it also provides hashes as well. Unfortunately, it also doesn't appear to use SHA-3.

MD5 ebc4bafbdd67acebe0658e8ab0ddbdec SHA-1 65473b0d1ccfb4490235b3e0fb8b276c49cee2c1 SHA-256 46754a93c17a7dfbc8a6ca7b1c74494ec4abc459e28049b4530634d06f2257d1

Python is my usual script and automation swiss-army knife, and its extensive standard library gets the job done. Python 3.11 adds the file_digest function to the hashlib module:

import hashlib path = 'sqlite-dll-win-x64-3500300.zip' with open(path, 'rb') as file: digest = hashlib.file_digest(file, 'sha3_256') print(digest.hexdigest())