crypto/basic_mod2
This commit is contained in:
parent
8ad492d0a6
commit
222558e2e3
|
@ -0,0 +1 @@
|
||||||
|
432 331 192 108 180 50 231 188 105 51 364 168 344 195 297 342 292 198 448 62 236 342 63
|
|
@ -0,0 +1,26 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# Take each number mod 41 and find the modular inverse for the result. Then map to the following character set: 1-26 are the alphabet, 27-36 are the decimal digits, and 37 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 %= 41
|
||||||
|
|
||||||
|
# NOTE: modular inverse
|
||||||
|
number = pow(number, -1, 41)
|
||||||
|
|
||||||
|
if number >=1 and number < 27:
|
||||||
|
print(chr(number - 1 + ord('A')), end="")
|
||||||
|
elif number >= 27 and number < 37:
|
||||||
|
print(number - 27, end="")
|
||||||
|
elif number == 37:
|
||||||
|
print('_', end="")
|
||||||
|
else:
|
||||||
|
print()
|
||||||
|
print(f"Code author seems to have forgotten a number.... {number}")
|
||||||
|
exit(1)
|
||||||
|
print("}")
|
Loading…
Reference in New Issue