分段解密
public string DecryptJava(string privateKeyJava, string data, string encoding = "UTF-8") { RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); rsa.FromPrivateKeyJavaString(privateKeyJava); byte[] encryptData = Convert.FromBase64String(data); byte[] dencryContent = null; #region 分段解密 if (encryptData == null || encryptData.Length <= 0) { throw new NotSupportedException(); } int keySize = rsa.KeySize / 8; byte[] buffer = new byte[keySize]; using (MemoryStream input = new MemoryStream(encryptData)) using (MemoryStream output = new MemoryStream()) { while (true) { int readLine = input.Read(buffer, 0, keySize); if (readLine <= 0) { break; } byte[] temp = new byte[readLine]; Array.Copy(buffer, 0, temp, 0, readLine); byte[] decrypt = rsa.Decrypt(temp, false); output.Write(decrypt, 0, decrypt.Length); } dencryContent = output.ToArray(); } #endregion return Encoding.UTF8.GetString(dencryContent); }