2022-08-08 00:58:46 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
# TODO: Actually break the hashes?
|
2022-09-02 11:23:25 +00:00
|
|
|
# TODONE in chernobreak.py
|
2022-08-08 00:58:46 +00:00
|
|
|
|
2022-09-02 11:23:25 +00:00
|
|
|
def hash(chars):
|
2022-08-08 00:58:46 +00:00
|
|
|
ret = 0;
|
2022-09-02 11:23:25 +00:00
|
|
|
for c in chars:
|
2022-08-08 00:58:46 +00:00
|
|
|
ret += c
|
|
|
|
ret = ((ret << 5) - ret) & 0xffff
|
|
|
|
return ret
|
|
|
|
|
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
line = input("> ")
|
2022-08-15 04:08:50 +00:00
|
|
|
if (len(line) and line[0] == '~'):
|
2022-08-08 00:58:46 +00:00
|
|
|
h = hash(bytes.fromhex(line[1:]));
|
|
|
|
else:
|
|
|
|
h = hash(line.encode())
|
2022-08-15 08:57:45 +00:00
|
|
|
print(f"hash: {h:x}, box[3]: {h&7:x}, box[4]: {h&0xf:x}");
|
2022-08-08 00:58:46 +00:00
|
|
|
except EOFError:
|
|
|
|
break
|
|
|
|
|
|
|
|
print("")
|