android rsa xml,RSA.ToXmlString(Boolean) 方法 (System.Security.Cryptography) | Microsoft Docs

创建并返回包含当前 RSA 对象的密钥的 XML 字符串。Creates and returns an XML string containing the key of the current RSA object.

public:

override System::String ^ ToXmlString(bool includePrivateParameters);

public override string ToXmlString (bool includePrivateParameters);

override this.ToXmlString : bool -> string

Public Overrides Function ToXmlString (includePrivateParameters As Boolean) As String

参数

includePrivateParameters

true 表示同时包含 RSA 公钥和私钥;false 表示仅包含公钥。true to include a public and private RSA key; false to include only the public key.

返回

包含当前 RSA 对象的密钥的 XML 字符串。An XML string containing the key of the current RSA object.

例外

仅限 .NET 5 及更高版本和 .NET Core:不支持此成员。.NET 5+ and .NET Core only: This member is not supported.

注解

ToXmlString方法创建一个 XML 字符串,该字符串包含当前对象的公钥和私钥, RSA 或者只包含当前对象的公钥 RSA 。The ToXmlString method creates an XML string that contains either the public and private key of the current RSA object or contains only the public key of the current RSA object.

ToXmlString需要方便地保留 RSA 密钥信息时,请使用方法。Use the ToXmlString method whenever you need to conveniently persist RSA key information. 若要 RSA 使用 XML 字符串中的密钥初始化对象,请使用 FromXmlString 方法。To initialize an RSA object with the key in an XML string, use the FromXmlString method.

注意

将包含私钥的 XML 字符串保存到不安全的位置是一项安全威胁。Persisting an XML string containing a private key to an insecure location is a security threat. 如果恶意的第三方可以访问您的私钥,则您的应用程序的安全性可能会受到威胁。The security of your application can be compromised if a malicious third party can access your private key. 若要安全地保留私钥,请使用安全密钥容器。To safely persist a private key, use a secure key container. 有关在密钥容器中保留私钥的详细信息,请参阅 如何:将非对称密钥存储在密钥容器中。For more information about persisting private keys in a key container, see How to: Store Asymmetric Keys in a Key Container.

当您传递 true 到 ToXmlString 方法时,生成的 XML 字符串将采用以下形式:When you pass true to the ToXmlString method, the resulting XML string takes the following form:

当您传递 false 到 ToXmlString 方法时,生成的 XML 字符串将采用以下形式:When you pass false to the ToXmlString method, the resulting XML string takes the following form:

适用于

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值