How to encrypt a large file in openssl using public key

后端 未结 8 1583
梦谈多话
梦谈多话 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:03

    You can't directly encrypt a large file using rsautl. instead, do something like the following:

    1. Generate a key using openssl rand, eg. openssl rand 32 -out keyfile
    2. Encrypt the key file using openssl rsautl
    3. Encrypt the data using openssl enc, using the generated key from step 1.
    4. Package the encrypted key file with the encrypted data. the recipient will need to decrypt the key with their private key, then decrypt the data with the resulting key.

提交回复
热议问题