Archived Forum Post

Index of archived forum posts

Question:

Encrypt a file with a RSA key

Aug 20 '15 at 09:43

Hello, I would like to encript a file using a public key generated with the RSA control, and decrypt it with the private key. I have found a example to encrypt/decrypt a string but not how encrypt a file. I have tried with "CkEncryptFile" method, but it does not run. (Only runs with a certificate). Is it posssible th encrypt/decrypt a file with a key generated with RSA control?

Thank in advance.

Victor Diego


Answer

RSA encryption is NEVER used for the encryption of bulk data. RSA would be used to generate a symmetric encryption key for a symmetric encryption algorithm such as AES, TwoFish, Blowfish, etc. The file data is then encrypted using this symmetric key w/ the symmetric algorithm. This is what happens when a certificate is used. The reverse process is to decrypt the symmetric key using RSA, and then use the decrypted symmetric key for the decryption of the bulk data.