Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

How to implement RSA encryption in AES?

The general principle is:

Code
Get a pair of RSA keys.
This is a pair of constant.
For the file, get the AES key.
This key is one-time and only applies to this file.
Encrypt AES key with RSA public key.
The encrypted block is always aligned to the same size.
Create a new file.
Write to it consistently: the encrypted AES key and information
AES encrypted key.
To read opens the file with the encrypted key and information. Reads an AES encrypted key.
Decrypt it with the RSA private key.
With the received key you decrypt the remaining information.
How to implement this principle of encryption?

I get a pair of Rsa keys:

Code
// Getkey(true); or Getkey(false);
public string GetKey(bool choice)
{
 string key = null;
 try
 {
   using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(2048))
   {
     if (choice)
     {
       key = rsa.ToXmlString(false);
     }
     else
     {
       key = rsa.ToXmlString(true);
     }
   }
 }
 catch (CryptographicException) { }
 return key;
}


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by putnik1313Jun 21, 2025 08:59 PM 12 436 Jun 21, 2025 08:59 PM
Last Post: Goods
by putnik1313May 26, 2025 03:04 PM 6 225 May 26, 2025 03:04 PM
Last Post: putnik1313
[C] by yuumiJun 5, 2022 06:30 PM 22 553 Jun 5, 2022 06:30 PM
Last Post: yuumi