
If it is necessary to store the ciphertext, it is recommended to store the raw ciphertext because of the Base64 overhead.

This string can then be passed to input() via copy/paste and Base64 decoded before decryption. The problem can be easily solved if the ciphertext is Base64 encoded. This character string must be converted back to the original byte string before decryption, which does not happen (or happens incorrectly) in the posted implementation (s. The byte string ciphertext is converted to a character string by str() or at the latest by input().Įxample: The 2 byte string b'\x11\xed' is converted by str() or by input() into an 11 bytes character string like a UTF8 encoding reveals: b"b'\\x11\\xed'". If anyone knows why this is, I would love some help. Whenever I encode text and then paste it into the input of the decryption program, it returns cannot decode message. Return rsa.verify(message, signature, key, ) = 'SHA-1'Ĭiphertext = input("message to decipher: ") Return rsa.decrypt(ciphertext, key).decode('ascii') Print(f"public key: ")Įncryptme = input('Write your message here:')Ĭiphertext = encrypt(encryptme, publicKey)Īnd in the decryption file I have: import rsa Return rsa.sign(message.encode('ascii'), key, 'SHA-1') Return rsa.encrypt(message.encode('ascii'), key)

With open('keys/privateKey.pem', 'rb') as p:

With open('keys/publicKey.pem', 'rb') as p: With open('keys/privateKey.pem', 'wb') as p: With open('keys/publicKey.pem', 'wb') as p: (publicKey, privateKey) = rsa.newkeys(1024) In the encryption file I have: import rsa So I am trying to make two programs, one to encode a message using rsa encryption, and one to decode it.
