Unable to decrypt RSA encrypted key

In short, I use DES, and I encrypt the password using RSA for key exchange, the password does not exceed 16 characters the problem is that when I encrypt the key, the encrypted size becomes too large for me to decrypt here my rsa encrypts and decrypts the code :

Encryption: - I try localpwd as "asd"

    byte[] plaintext = utf8.GetBytes(localpwd);
    byte[] ciphertext = rsaservice.Encrypt(plaintext, false);
    string cipherresult = Convert.ToBase64String(ciphertext);

then type the encrypted key in the text box and try to decrypt

    byte[] ciphertext = utf8.GetBytes(filetest.Text);
    byte[] plain = rsaservice.Decrypt(ciphertext, true);
    string plaintext = utf8.GetString(plain);

I get "the decrypted data exceeds the maximum 256 bytes for this module." I tried to increase the key size in order to be able to encrypt and decrypt large key sizes, but increasing the key just increases the size of the encrypted data, which leads to the same error, please help !!!

+3
1
//byte[] ciphertext = utf8.GetBytes(filetest.Text);
  byte[] ciphertext = Convert.FromBase64String(filetest.Text);
+5

All Articles