-
-
Notifications
You must be signed in to change notification settings - Fork 383
Expand file tree
/
Copy pathgenHashRounds.py
More file actions
executable file
·49 lines (38 loc) · 1.62 KB
/
Copy pathgenHashRounds.py
File metadata and controls
executable file
·49 lines (38 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python3
import binascii
import hashlib
def main():
hash_funcs = [
("SHA-1", hashlib.sha1),
("SHA-224", hashlib.sha224),
("SHA-256", hashlib.sha256),
("SHA-384", hashlib.sha384),
("SHA-512", hashlib.sha512),
("SHA3-224", hashlib.sha3_224),
("SHA3-256", hashlib.sha3_256),
("SHA3-384", hashlib.sha3_384),
("SHA3-512", hashlib.sha3_512),
]
for (sha_type, sha_func) in hash_funcs:
digest = sha_func("abc".encode()).digest()
# Only loop 4 times since an iteration was done above
for _ in range(0, 4):
digest = sha_func(digest).digest()
print("{:>8} with 5 Rounds: {}".format(sha_type, binascii.hexlify(digest).decode()))
# Loop another 5 times to get to 10
for _ in range(0, 5):
digest = sha_func(digest).digest()
print("{:>8} with 10 Rounds: {}".format(sha_type, binascii.hexlify(digest).decode()))
hash_funcs = [("SHAKE128", hashlib.shake_128), ("SHAKE256", hashlib.shake_128)]
for (sha_type, sha_func) in hash_funcs:
digest = sha_func("abc".encode()).digest(31)
# Only loop 4 times since an iteration was done above
for _ in range(0, 4):
digest = sha_func(digest).digest(31)
print("{:>8} with 5 Rounds: {}".format(sha_type, binascii.hexlify(digest).decode()))
# Loop another 5 times to get to 10
for _ in range(0, 5):
digest = sha_func(digest).digest(31)
print("{:>8} with 10 Rounds: {}".format(sha_type, binascii.hexlify(digest).decode()))
if "__main__" == __name__:
main()