.net rsa公钥解密
.net 有给定的密文和公钥,怎么用rsa公钥来解密?
给定的密文: string en = "V/5/99ubmARZ0uOT/KOBrOdns/91mm23mAGDvfvgJjhG36/R82QaaEQrD7+vIR7850Hx03wZr7QcdIy2CGiEB+p5lgKDjU8FAQAjwLxqIWNT0T8ugdwGiMI3pC/SKlY3I0mKtoN78YNIgFLWA5QM0xSWvjls5p7hLbs4cZz6Oe4=";
给定的公钥: string toXmlPublicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC6IB26O/Elia0G3ccaQhub2XNQPUfdRolnpNDdfh5mehb0VoOHP3EoVpsRgsVEpPfIFw/XtaZX3CfwC4Dp5aq0uZolTd+Lk7t+EKV/xQ+voDexN3u4MZLsGUW+p/VYAkajING//U8cIkEBws6Rk+ZDZVhrz+p+aBsXAY3XVCpU2QIDAQAB";
解密的代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
namespace RSATest
{
/// <summary>
/// 非对称RSA加密类 可以参考
/// http://www.cnblogs.com/hhh/archive/2011/06/03/2070692.html
/// http://blog.csdn.net/zhilunchen/article/details/2943158
/// 若是私匙加密 则需公钥解密
/// 反正公钥加密 私匙来解密
/// 需要BigInteger类来辅助
/// </summary>
public static class RSAHelper
{
/// <summary>
/// RSA的容器 可以解密的源字符串长度为 DWKEYSIZE/8-11
/// </summary>
public const int DWKEYSIZE = 1024;
/// <summary>
/// RSA加密的密匙结构 公钥和私匙
/// </summary>
public struct RSAKey
{
public string PublicKey { get; set; }
//public string PrivateKey { get; set; }
}
#region 得到RSA的解谜的密匙对
/// <summary>
/// 得到RSA的解谜的密匙对
/// </summary>
/// <returns></returns>
public static RSAKey GetRASKey()
{
string toXmlPublicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC6IB26O/Elia0G3ccaQhub2XNQPUfdRolnpNDdfh5mehb0VoOHP3EoVpsRgsVEpPfIFw/XtaZX3CfwC4Dp5aq0uZolTd+Lk7t+EKV/xQ+voDexN3u4MZLsGUW+p/VYAkajING//U8cIkEBws6Rk+ZDZVhrz+p+aBsXAY3XVCpU2QIDAQAB";
byte[] publicKey = Encoding.Default.GetBytes(toXmlPublicKey);
byte[] exponent = { 1, 0, 1 };
&n