RSA Key Encryption over TCPAuthor: Matt MacDonald Here is a small example of setting up RSA encryption over a TCP port connection. Client Side: Make a connection to a server that you want to send encrypted data to:
Make a blank RSA key and wait to fill it from the server:
Generate an encrypt/decrypt key for this session and encrypt it using fileserve's public key and send it to fileserve:
Server Side: With client connection already listening (see earlier cookbook examples), generate an RSA key and send the public portion of the key to the client:
Get the client's encrypted encryption key:
Decrypt it using our private key:
From this point on, your code can exchange data using the crypt-key with standard symmetric encryption for encrypting and decrypting data sent between the client and the server. |