简体   繁体   中英

Cannot Decrypt RSA encrypted Key

Long story short, I'm using DES and I'm encrypting a password using RSA for key exchange, the password does not exceed 16 characters the problem is when i encrypt the key, the encrypted size becomes too big for me to decrypt here's my rsa encrypt and decrypt code:

Encrypt:--i've been trying the localpwd as "asd"

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

then i print the encrypted key on the textbox and try decrypting

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

i get "the data to be decrypted exceeds the maximum for this modulus of 256 bytes". i tried increasing the key size to be able to encrypt and decrypt larger key sizes, but increasing the key just increases the size of the encrypted data resulting in the same error please help!!!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM