

Print(f"Received: ")Įncoded_ciphertext = base64.

# Decrypt the ciphertext using the private keyįor i in range(0, len(decoded_data), 256):

Ssl_sock = context.wrap_socket(client_sock, server_side=True) from Crypto.PublicKey import RSA from Crypto.Signature import PKCS1v15 from base64 import b64decode rsakey RSA.importKey (open ('private.txt', 'rb').read ()) cipher PKCS1v15. Print("Connection established from", client_address) # Bind the socket to a specific address and portĬlient_sock, client_address = sock.accept() Sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) Here is the code for my server (please note: my computer is currently acting as both server and client): import socketįrom import rsa, paddingįrom import serialization, hashesįrom import default_backendĬontext = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)Ĭontext.load_cert_chain(certfile="server.crt", keyfile="server.key") I've tried to edit the code, changing the key size and the size of the sent data, but the error remains. Here is my error:Įrror: Ciphertext length must be equal to key size. I've got STL/TLS to work, and now I'm working on end-to-end encryption. I'm trying to make an end-to-end encrypted messenger in Python.
