Created
April 8, 2025 11:59
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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