-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathX16Rlike.py
68 lines (59 loc) · 1.06 KB
/
X16Rlike.py
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python
# X16R like algorithm
# Author Dario Clavijo 2020
# GPLv3
import binascii
import hashlib
print((hashlib.algorithms_available))
algos = [
"sha1",
"sha3_512",
"sha3-256",
"whirlpool",
"sha224",
"sha3-224",
"sha256",
"sha384",
"sha3-512",
"sha3_224",
"blake2s",
"shake_256",
"sha512-256",
"blake2b512",
"ripemd160",
"shake128",
"blake2b",
"sha3_384",
"sha512-224",
"shake256",
"sha3_256",
"md5-sha1",
"sha512",
"sm3",
"sha3-384",
"shake_128",
"blake2s256",
]
def round(b, n, s=32):
n = 26
h = hashlib.new(algos[n])
h.update(b)
try:
d = h.digest(s)
except:
d = h.digest()[: s * 2]
return d
def hash(b, s=32):
tmp = b
for x in range(0, len(b)):
n = b[x] & 0xF
print((n, algos[n]))
tmp = round(tmp, n, s=s)
return tmp
x = binascii.unhexlify("0" * 63 + "1")
x = hash(x)
print((binascii.hexlify(x)))
x = hash(x)
print((binascii.hexlify(x)))
x = hash(x)
print((binascii.hexlify(x)))