如何存储/检索RSA公钥/私钥 [英] How to store/retrieve RSA public/private key

查看:532
本文介绍了如何存储/检索RSA公钥/私钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用RSA公钥加密。什么是存储或检索私钥和公钥的最佳方式? XML是这里一个好主意?

I want to use RSA public key encryption. What is the best way to store or retrieve private and public keys? Is XML a good idea here?

如何拿到钥匙?

RSAParameters privateKey = RSA.ExportParameters(true);
RSAParameters publicKey = RSA.ExportParameters(false);

由于RSAParameters有以下成员:D,DP,DQ指数,InverseQ,模量,P,Q

Because RSAParameters have the following members: D, DP, DQ, Exponent, InverseQ, Modulus, P, Q

哪一个是关键?

推荐答案

我已经成功做的是存储密钥为XML。有两种方法中的RSACryptoServiceProvider:ToXMLString和FromXMlString。作用与toXMLString将返回包含要么只是公钥数据或公共和私有密钥的数据取决于你如何设置它的参数,XML字符串。当提供了含有要么只是公钥数据或公共和私有密钥数据的XML字符串FromXMLString方法将填充相应的密钥数据的RSACryptoServiceProvider。

What I have done successfully is to store the keys as XML. There are two methods in RSACryptoServiceProvider: ToXMLString and FromXMlString . The ToXMLString will return an XML string containing either just the public key data or both the public and private key data depending on how you set it's parameter. The FromXMLString method will populate the RSACryptoServiceProvider with the appropriate key data when provided an XML string containing either just the public key data or both the public and private key data.

这篇关于如何存储/检索RSA公钥/私钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆