关于rsa解密.总是报错.
public string jieme(string sEncrypted)
{
int iMaxLength = 117;//一次加密的最大字节数
int iKeyLength = 3096;
byte[] decryptedData;//解密后的数据
string str = " ";
try
{
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(iKeyLength);
int iDecryptLength = (iKeyLength / 1024) * 172; //每次需要解密的字节数
int iDecrypt = sEncrypted.Trim().Length/iDecryptLength; //解密次数
string sDecrypted = " "; //解密后的字符串
int iByte = (iDecrypt + 1) * iMaxLength;
byte[] bDecrypted = new Byte[iByte]; //解密后的字节信息
for (int i = 0; i < iDecrypt + 1; i++)
{
string sToDecrypted = " ";
//把待解密的字符串分段
if (i == iDecrypt)
{
sToDecrypted = sEncrypted.Substring(i * iDecryptLength, sEncrypted.Length - i * iDecryptLength);
}
else
{
sToDecrypted = sEncrypted.Substring(i * iDecryptLength, iDecryptLength);
}
if (sToDecrypted != null && sToDecrypted != " ")
{
byte[] bToDecrypt = Convert.FromBase64String(sToDecrypted); //得到待解密的字节信息
decryptedData =RSA.Decrypt(bToDecrypt, false);//解密
System.Buffer.BlockCopy(decryptedData, 0, bDecrypted, i * iMaxLength, decryptedData.Length);//得到解密后的字节信息
}
sDecrypted += System.Text.Encoding.Default.GetString(bDecrypted); //得到解密后的字符串
}
str += "Decrypted buff: " + sDecrypted + '\n ';
return sDecrypted;
}
catch (Exception e1)
{
throw e1;
}
}
[解决办法]
沙发,不懂帮顶
[解决办法]
帮LZ顶
http://user.qzone.qq.com/31767702
[解决办法]
我的天
要回去翻安全保密技术了