picoctf/crypto/basic_mod1/solve.py

23 lines
663 B
Python
Raw Normal View History

2024-09-02 20:20:46 +02:00
#!/usr/bin/env python3
# Take each number mod 37 and map it to the following character set: 0-25 is the alphabet (uppercase), 26-35 are the decimal digits, and 36 is an underscore.
with open('message.txt') as file:
content = file.read().strip()
print("picoCTF{", end="")
for n in content.split(' '):
number = int(n)
number %= 37
if number < 26:
print(chr(number + ord('A')), end="")
elif number >= 26 and number < 36:
print(number - 26, end="")
elif number == 36:
print('_', end="")
else:
print()
print(f"Code author seems to have forgotten a number.... {number}")
exit(1)
print("}")