日期:2014-05-20  浏览次数:21091 次

关于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