I am developing an encryption application but I do not have good ideas about how exchange the private key as securely around the internet. I have some simple ideas like combine some data with client's mac address + minute but I do not mind it will work correctly. Could you guide me?

I need something that is exchanging the keys like Tor.


2 Answers 2


Do not attempt to implement key exchange on your own. You should be using a standard library which makes this easy, such as libsodium. See the documentation on how to do that.


The purpose of asymmetric encryption is to eliminate the key exchange problem entirely. With public key crypto, you can publish your public key without concern. However, your private key should remain private and should not be transferred. I would highly recommend getting a grasp on public key cryptography, and as was stated in a previous answer, do not attempt to come up with your own cryptographic algorithm. Use a well-tested solution.

  • 1
    It does not eliminate the key exchange problem, but solves it. When you send encrypted data, it is first encrypted with a symetric encryption algo and a random key, then the symetric key in encrypted with the public key of the recipient. Both the encrypted data (symetric encryption) and the encrypted random key (asymetric encryption) and sent. Then the recipient decrypts the random key with its own private key and at the end decrypts the payload. It may look complex, but asymetric encryption does not suit well with large data. Dec 20, 2017 at 16:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .