Hashing and Checksums
May 30, 2026 | 5 min read
Simple Checksum
def checksum(data: bytes) -> int:
total = 0
for b in data:
total = (total + b) & 0xff
return total
FNV-1a Hash
def fnv1a(data: bytes) -> int:
hash_val = 0x811c9dc5
for b in data:
hash_val ^= b
hash_val *= 0x01000193
hash_val &= 0xffffffff
return hash_val
When to Use hashlib
For SHA-256, MD5, and BLAKE3, use hashlib — these are C-accelerated. Use Pyvorin for custom or non-cryptographic hashes.