-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
impl hashlib like interface for testing
- Loading branch information
1 parent
39b5f11
commit 21f3125
Showing
3 changed files
with
30 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,26 @@ | ||
import random | ||
from hashlib import shake_128 | ||
from xof_py import shake_123 | ||
|
||
from xof_py import pyo3_shake_128 | ||
import time | ||
import os | ||
|
||
for _ in range(100): | ||
absorb = os.urandom(32) | ||
n = random.randint(1, 1000) | ||
a = shake_128(absorb).digest(n) | ||
b = pyo3_shake_128(absorb, n) | ||
assert a == b | ||
|
||
random.seed(0) | ||
t0 = time.time() | ||
for _ in range(10_000): | ||
a = shake_123() | ||
n = random.randint(1, 5000) | ||
a = pyo3_shake_128(b"123", n) | ||
print(f"10_000 calls with rust sha3: {time.time() - t0 }") | ||
|
||
random.seed(0) | ||
t0 = time.time() | ||
for _ in range(10_000): | ||
a = shake_128(b"123").digest(10) | ||
print(f"10_000 calls with hashlib: {time.time() - t0}") | ||
n = random.randint(1, 5000) | ||
a = shake_128(b"123").digest(n) | ||
print(f"10_000 calls with hashlib: {time.time() - t0}") |
This file contains 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