def run(self, text): """ Run the automatic key finding """ # simply brute force the 26 possibilities self.set_total_possibilities(26) for i in range(26): self.possibility(i, caesar(text, -i)) self.done()
# Design the layout of the home window layout = [[sg.Text('Welcome to emailEncryptor', auto_size_text=False, justification='center', font=('Helvetica', 20))], [sg.Text('')], [sg.Text('Written by Hayden Riewe', auto_size_text=False, justification='center', font=('Helvetica', 20))], [sg.Text('')], [sg.Text('',size=(14,1)), sg.Button('Send', font = ('Helvetica',15), auto_size_button=True), sg.Button('Decode', font=('Helvetica',15), auto_size_button=True), sg.Quit(font=('Helvetica',15),auto_size_button=True)]] # Show the Window to the user window = sg.Window('Welcome to emailEncryptor!').Layout(layout) # Event loop. Read buttons, make callbacks while True: # Read the Window button, value = window.Read() # Take appropriate action based on button if button == 'Send': window.Hide() sendMailButton() elif button == 'Decode': window.Hide() decodeMailButton() elif button =='Quit' or button is None: sys.exit() break # Function call to create instance of classes and to start the program realSteg = realSteg() caesar = caesar() home()
from collections import Counter from ciphers import caesar with open('4.txt') as f: lines = [l.replace('\n', '') for l in f.readlines()] s = 0 for line in lines: line = line.split('-') name = ''.join(line[:-1]) check = line[-1].split('[')[-1][:-1] number = int(line[-1].split('[')[0]) counts = dict(Counter(name)).items() counts = sorted(counts, key=lambda x: (-x[1], x[0])) if ''.join([c[0] for c in counts[:5]]) == check: s += number name = ' '.join(line[:-1]) decoded = caesar(name, number) if 'north' in decoded: print(decoded, number)
else: shift = args.shift if args.horizontal_shift != 4: h_shift = int(''.join(args.horizontal_shift)) else: h_shift = args.horizontal_shift print(args) key = None for m in args.cipher: if m == 'r': final_message = cipher.reverse(final_message, method) elif m == 'c': final_message = cipher.caesar(final_message, method, shift) elif m == 'n': final_message = cipher.char_num(final_message, method) elif m == 'h': final_message = cipher.horizontal_matrix(final_message, method, h_shift) elif m == 'a': final_message = cipher.alternate(final_message, method) elif m == 'ra': final_message, key = cipher.random_key(final_message, method, args.key) if args.clear == True: try: if platform.startswith('win32'): subprocess.run("cls", shell=True, check=True) else: