本书中247页倒数第二行中提到“公钥可以从已签名数据中提取”
rsa类有提取公钥的方法吗? (好像没有)
那用什么方法提取签名数据中公钥呢?
有知道的朋友说说操作方法,谢谢!
//私钥
<RSAKeyValue><Modulus>oMKny8OPBTAI4qmLTTsAGlQkPVGUCr1OQht2XRCoDG09hcXl3+SO98bVLjYZLda2uXRXWw0MBSJJug7M27sjfhsZkFd+fFLXzVd2D7JbcoGb5tmKdThsiH2mQllJY0aimnQoDrz9F/o3pbb2Q+LFNKiMlLhHW/z7KDbqk/M7+AE=</Modulus><Exponent>AQAB</Exponent><P>3PjOU+kuPMVKfWje66gP3mQGgcRzcRFaVBCwdBFlAXki50rNz12CaAajtn9Bt24y05Gjs2wqtiLd51Z8L0jQxw==</P><Q>uj5seFOUfGrEe0l80bNDpD/jV8xiU3+jc60DExnw8EaOtzdCvVDy5ONWl/AsEYtHy6lBKnw/rO1Y2fZ2xjk49w==</Q><DP>amClA6RYDA12hNU9q/kmWouQzlwCr0YJVDsMl3PgSktE0FAksFV1+BpqKested7lPRD52+CQ10oFxd7Ovfyx9Q==</DP><DQ>H4btqbjMS/tu40ffX0gvTSCbhYNNqcDTlINXH+amSKZJBm7OV2nalDB/uhyn+RhQwQMXyu9ZgBZ1kgAMvyV0pQ==</DQ><InverseQ>b3AzgVBNHQj5Z4tNGsn/Fp081Im9agRLlfHSA4ynsd45+BxM8PS9I3j0bpDvvqbUSgsbpNVtAPzPBk4P+fQt3g==</InverseQ><D>KrkwsNVrB/zpD5vxWngIofaknus0RdpjluwHe9o2Xv8VL50VZ3gtiqn788kKzgTXENhbcuY3wJGJOHpAdVD5sFi4aPWWZQXx74Tty8Cb5KDsNP+uTnMS8H1Brdsng3GA0FIfSDt8Wn1mO9yOoQ2/99QMMoj9XIYES2Fvn95ucGU=</D></RSAKeyValue>
//公钥
<RSAKeyValue><Modulus>oMKny8OPBTAI4qmLTTsAGlQkPVGUCr1OQht2XRCoDG09hcXl3+SO98bVLjYZLda2uXRXWw0MBSJJug7M27sjfhsZkFd+fFLXzVd2D7JbcoGb5tmKdThsiH2mQllJY0aimnQoDrz9F/o3pbb2Q+LFNKiMlLhHW/z7KDbqk/M7+AE=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>
// 密文
?慄対ь謹?]|廗眓翤侩??雙稻 Z!>谳
3w?﨤阥ζ鋦胀R3荝?<锪錳嚃饌 Ab襺b蹽 :fk?xF?z?72}5漽*}i 耚騁dJF[9?8@
// 明文
www.wade.cn
// 加密解密程序代码
private void button20_Click(object sender, EventArgs e)
{
// 加密
byte[] p=Encoding.UTF8.GetBytes("www.wade.cn");
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
// 导入公钥
StreamReader reader = new StreamReader("c:\\pris.xml");
string pubstr = reader.ReadToEnd();
rsa.FromXmlString(pubstr);
// 生成rsa密钥(包括public和private)
/*
string pristr = rsa.ToXmlString(true);
string pubstr = rsa.ToXmlString(false);
Stream pris = File.Create("c:\\pris.txt");
pris.Write(Encoding.UTF8.GetBytes(pristr), 0, pristr.Length);
pris.Close();
Stream pubs = File.Create("c:\\pubs.txt");
pubs.Write(Encoding.UTF8.GetBytes(pubstr), 0, pubstr.Length);
pubs.Close();
*/
byte[] o=rsa.Encrypt(p, false);
Stream ss=File.Create("c:\\pubout.txt");
ss.Write(o,0,o.Length);
ss.Close();
MessageBox.Show ("over");
}
private void button21_Click(object sender, EventArgs e)
{
// 解密
Stream s = File.Open("c:\\2.txt", FileMode.Open);
byte[] c = new byte[s.Length];
s.Read(c,0,c.Length);
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
StreamReader reader = new StreamReader("c:\\pris.xml");
string privatestr = reader.ReadToEnd();
rsa.FromXmlString(privatestr);
byte[] o = rsa.Decrypt(c, false);
// 显示明文
MessageBox.Show(Encoding.UTF8.GetString(o));
}
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课