mirror of
https://git.soft.fish/val/MicroCorruption.git
synced 2025-10-30 16:29:13 +00:00
Move this to a new folder for bad python
This commit is contained in:
24
17-Chernobyl/Code/crappy_python/hashfunc.py
Normal file
24
17-Chernobyl/Code/crappy_python/hashfunc.py
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# TODO: Actually break the hashes?
|
||||
# TODONE in chernobreak.py
|
||||
|
||||
def hash(chars):
|
||||
ret = 0;
|
||||
for c in chars:
|
||||
ret += c
|
||||
ret = ((ret << 5) - ret) & 0xffff
|
||||
return ret
|
||||
|
||||
while True:
|
||||
try:
|
||||
line = input("> ")
|
||||
if (len(line) and line[0] == '~'):
|
||||
h = hash(bytes.fromhex(line[1:]));
|
||||
else:
|
||||
h = hash(line.encode())
|
||||
print(f"hash: {h:x}, box[3]: {h&7:x}, box[4]: {h&0xf:x}");
|
||||
except EOFError:
|
||||
break
|
||||
|
||||
print("")
|
||||
Reference in New Issue
Block a user