Click here to Skip to main content
14,638,655 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hello Experts,

I made one small desktop application in My requirement is i want to encrypt a text file using RSA Algorithm. I already done this encyption using CAPICOMM.dll, but now I want to do it using RSA Algorithm in which I will use Public key to encrypt the file and Private key to decrypt the encrypted file.

Below is my code that I implemented but it gives me an error!!:confused:

UnicodeEncoding ByteConverter = new UnicodeEncoding();
byte[] dataToEncrypt = ByteConverter.GetBytes("Hello there");
byte[] encryptedData;
byte[] decryptedData;
//Create a new instance of RSACryptoServiceProvider to generate
//public and private key data.
//CspParameters param = new CspParameters(
using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider())
    //Pass the data to ENCRYPT, the public key information
    encryptedData = RSA.Encrypt(dataToEncrypt, false);
    //Pass the data to DECRYPT, the private key information
    decryptedData = RSA.Decrypt(encryptedData, false);
    //Display the decrypted plaintext

Need your suggestion. Thanks in advance...

[edit]Tags, minor spelling - OriginalGriff[/edit]
Updated 13-Jul-10 1:12am
OriginalGriff 13-Jul-10 7:13am
What error do you get? Where do you get it?
Is it a run time error - if so, what is the exception?

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

I think you can find ,understand and use the method that is Here
Hope this helps... ;P

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100