mirror of
https://git.soft.fish/val/MicroCorruption.git
synced 2024-11-23 00:25:58 +00:00
25 lines
491 B
Python
25 lines
491 B
Python
#!/usr/bin/env python3
|
|
|
|
# TODO: Actually break the hashes?
|
|
# May not be necessary, just gotta find a way to crash it. Harumph.
|
|
|
|
def hash(byts):
|
|
ret = 0;
|
|
for c in byts:
|
|
ret += c
|
|
ret = ((ret << 5) - ret) & 0xffff
|
|
return ret
|
|
|
|
while True:
|
|
try:
|
|
line = input("> ")
|
|
if (line[0] == '~'):
|
|
h = hash(bytes.fromhex(line[1:]));
|
|
else:
|
|
h = hash(line.encode())
|
|
print(f"hash: {h:x}, box: {h&7:x}");
|
|
except EOFError:
|
|
break
|
|
|
|
print("")
|