ROT-code/breakrot.py

29 lines
791 B
Python
Raw Normal View History

2022-05-22 18:11:11 +02:00
#!/usr/bin/env python3.10
2022-05-22 18:07:02 +02:00
from rot import rot
2022-05-15 15:04:38 +02:00
from sys import argv
from collections import Counter
2022-05-22 18:07:02 +02:00
def breakRot(m: str, f: str, x: int):
t=tuple(open(f).read().splitlines()[:x])
2022-05-22 18:07:02 +02:00
poss=[]
for i in range(1, 26):
msg=rot(m, -i)
print(f"{i}: {msg}")
2023-02-07 14:54:30 +01:00
for j in t:
if j.upper() in msg.upper():
2022-05-22 18:07:02 +02:00
poss.append(msg)
2023-02-07 14:54:30 +01:00
counter = Counter(poss)
return f"\033[1;32m {counter} \033[3;32m"
if __name__ == "__main__":
try:
a=argv[1]
b=argv[2]
c=int(argv[3])
except IndexError:
a=input("Give encoded text to break: ")
b=input("Give filename of file which contains wordlist: ")
c=int(input("Type how many words to read from the wordlist ('-1'=every): "))
2022-05-22 18:07:02 +02:00
print(breakRot(a, b, c))