def RuntimeTest(self): data = self.testData.strip().split('\n') for i in range(len(data)): start = time() des = DES() key = '0001001100110100010101110111100110011011101111001101111111110001' des.SetKey(key) des.EncryptKey() des.SetInputText(data[i]) des.SetCipherText(des.Encrypt()) desResult = des.Decrypt() stop = time() self.runtime += ('DES runtime:' + str(stop - start) + "s\n") start = time() rsa = RSA() rsa.KeyGeneration(128) rsaResult = rsa.Decryption( rsa.Encryption(int(data[i]), rsa.keyPublic, rsa.n), rsa.keyPrivate, rsa.n) stop = time() self.runtime += ('RSA runtime:' + str(stop - start) + "s\n\n") return self.runtime
def send_button_processing(): encryption_message = RSA.Encryption(messageEntry.get(1.0, END), int(publicKeyEntry.get()), int(n_Value_of_public_entry.get()), int(privateKeyEntry.get()), int(n_Value_of_private_entry.get())) print(encryption_message) socket_client.send(encryption_message) statusLabel['text'] = "Message sent successfully"
if __name__ == '__main__': while True: print("Please input command:") print("0) Generate public and private key") print("1) Encryption") print("2) Decryption") print("3) Exit") command = input("> ") if command == "0": print("Generate 1024 bits key...") n, p, q, pub_key, pri_key = RSA.KeyGenerator() print("N: %X" % n) print("p: %X" % p) print("q: %X" % q) print("Public key: %X" % pub_key) print("Private key: %X" % pri_key) print("") elif command == "1": n = int(input("Input n(base 16): "), 16) key = int(input("Input key(base 16): "), 16) message = int(input("Input message(base 16): "), 16) print("\nResult: %X\n" % RSA.Encryption(n, key, message)) elif command == "2": n = int(input("Input n(base 16): "), 16) p = int(input("Input p(base 16): "), 16) q = int(input("Input q(base 16): "), 16) key = int(input("Input key(base 16): "), 16) message = int(input("Input message(base 16): "), 16) print("\nResult: %X\n" % RSA.DecryptionCRT(n, p, q, key, message)) else: break