无法解密RSA加密的密钥 [英] Cannot Decrypt RSA encrypted Key

查看:273
本文介绍了无法解密RSA加密的密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

长话短说,我使用的DES和我加密使用RSA密钥交换密码,密码不超过16个字符
的问题是,当我加密​​密钥,加密的规模变得太大大对我来说,解密
,这里是我的RSA加密和解密代码:



加密: - 我一直在努力的localpwd为ASD

 字节[] =明文utf8.GetBytes(localpwd); 
字节[] =密文rsaservice.Encrypt(明文,FALSE);
串cipherresult = Convert.ToBase64String(密文);



然后我打印的文本框中加密的密钥,并尝试解密

 字节[] =密文utf8.GetBytes(filetest.Text); 
字节[] =平原rsaservice.Decrypt(密文,真);
字符串明文= utf8.GetString(平原)



我得到被解密的数据超过最大此模数的256字节。 $ B $双向试图增加密钥大小,以便能够加密和解密较大密钥长度,但增加了键只是增加导致相同的错误
中的加密的数据的大小,请帮助!!!


解决方案

  //字节[] =密文utf8.GetBytes(filetest.Text); 
字节[] =密文Convert.FromBase64String(filetest.Text);


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);

这篇关于无法解密RSA加密的密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆