How to encrypt a large file in openssl using public key

后端 未结 8 1573
梦谈多话
梦谈多话 2020-12-04 05:27

How can I encrypt a large file with a public key so that no one other than who has the private key be able to decrypt it?

I can make RSA public and private keys but

8条回答
  •  再見小時候
    2020-12-04 06:04

    Public-key crypto is not for encrypting arbitrarily long files. One uses a symmetric cipher (say AES) to do the normal encryption. Each time a new random symmetric key is generated, used, and then encrypted with the RSA cipher (public key). The ciphertext together with the encrypted symmetric key is transferred to the recipient. The recipient decrypts the symmetric key using his private key, and then uses the symmetric key to decrypt the message.

    The private key is never shared, only the public key is used to encrypt the random symmetric cipher.

提交回复
热议问题