Cannot Decrypt RSA encrypted Key

╄→尐↘猪︶ㄣ 提交于 2019-12-02 01:16:35

问题


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!!!


回答1:


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


来源:https://stackoverflow.com/questions/10362409/cannot-decrypt-rsa-encrypted-key

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!