资 源 简 介
在密钥容器中创建非对称密钥、在密钥容器中删除非对称密钥、在密钥容器中获取非对称密钥,具体的实现代码,请参考如下代码:
private void button1_Click(object sender, EventArgs e)
{//在密钥容器中创建非对称密钥
CspParameters MyCSP = new CspParameters();
MyCSP.KeyContainerName = this.textBox2.Text;
RSACryptoServiceProvider MyRSA = new RSACryptoServiceProvider(MyCSP);
this.textBox1.Text=MyRSA.ToXmlString(true);
}
private void button2_Click(object sender, EventArgs e)
{//在密钥容器中删除非对称密钥
CspParameters MyCSP = new CspParameters();
MyCSP.KeyContainerName = this.textBox2.Text;
RSACryptoServiceProvider MyRSA = new RSACryptoServiceProvider(MyCSP);
MyRSA.PersistKeyInCsp = false;
MyRSA.Clear();
try
{
this.textBox1.Text = MyRSA.ToXmlString(true);
}
catch
{
this.textBox1.Text = "已经删除非对称密钥!";
}
}
private void button3_Click(object sender, EventArgs e)
{//在密钥容器中获取非对称密钥
CspParameters MyCSP = new CspParameters();
MyCSP.KeyContainerName = this.textB