def possible_keys(self): caesar = Caesar() multiplication = Multiplication() multiplication_keys = multiplication.possible_keys() caesar_keys = caesar.possible_keys() keys = [] for key in multiplication_keys: for c_key in caesar_keys: keys.append((key, c_key)) return keys
def main(): """Main function to be run""" test_ciphers() text = 'ENCODED' key = 3 caesar = Caesar() sender = Sender(key, caesar) receiver = Receiver(key, caesar) encoded = sender.operate_cipher(text) receiver.operate_cipher(encoded) hacker = Hacker(caesar.possible_keys(), caesar) hacker.operate_cipher(encoded) print() multiplication = Multiplication() sender.set_cipher_algorithm(multiplication) receiver.set_cipher_algorithm(multiplication) encoded = sender.operate_cipher(text) receiver.operate_cipher(encoded) hacker.set_cipher_algorithm(multiplication) hacker.operate_cipher(encoded) print() affine = Affine() sender.set_cipher_algorithm(affine) receiver.set_cipher_algorithm(affine) key = (3, 3) sender.set_cipher_key(key) receiver.set_cipher_key(key) encoded = sender.operate_cipher(text) receiver.operate_cipher(encoded) hacker.set_cipher_key(affine.possible_keys()) hacker.set_cipher_algorithm(affine) hacker.operate_cipher(encoded) print() unbreakable = Unbreakable() key = 'ABIDE' sender.set_cipher_algorithm(unbreakable) receiver.set_cipher_algorithm(unbreakable) sender.set_cipher_key(key) receiver.set_cipher_key(key) encoded = sender.operate_cipher(text) receiver.operate_cipher(encoded) hacker.set_cipher_algorithm(unbreakable) #hacker.set_cipher_key(unbreakable.possible_keys()) #hacker.operate_cipher(encoded) hacker.crack_unbreakable(encoded)