Skip to content

Instantly share code, notes, and snippets.

@iwconfig
Created April 8, 2025 11:59
Show Gist options
  • Save iwconfig/12b457dd6815988e9d5581ad16b1cca3 to your computer and use it in GitHub Desktop.
Save iwconfig/12b457dd6815988e9d5581ad16b1cca3 to your computer and use it in GitHub Desktop.
Compare performance of SHA-256 and BLAKE2 on your CPU. Useful for choosing encryption mode for Borg repositories, for example.
import hashlib
import time
data = b'a' * (10**6) # 1 MB of data
# Benchmark SHA-256
start = time.time()
for _ in range(1000):
hashlib.sha256(data).hexdigest()
print("SHA-256 time:", time.time() - start)
# Benchmark BLAKE2
start = time.time()
for _ in range(1000):
hashlib.blake2b(data).hexdigest()
print("BLAKE2 time:", time.time() - start)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment