Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

RSA.ToXmlString Method

Creates and returns an XML string containing the key of the current RSA object.

Namespace: System.Security.Cryptography
Assembly: mscorlib (in mscorlib.dll)

public override string ToXmlString (
	bool includePrivateParameters
)
public String ToXmlString (
	boolean includePrivateParameters
)
public override function ToXmlString (
	includePrivateParameters : boolean
) : String

Parameters

includePrivateParameters

true to include a public and private RSA key; false to include only the public key.

Return Value

An XML string containing the key of the current RSA object.

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.

Use the ToXmlString method whenever you need to conveniently persist RSA key information. To initialize an RSA object with the key in an XML string, use the FromXmlString method.

Caution noteCaution

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.

When you pass true to the ToXmlString method, the resulting XML string takes the following form:

<RSAKeyValue>
   <Modulus>…</Modulus>
   <Exponent>…</Exponent>
   <P>…</P>
   <Q>…</Q>
   <DP>…</DP>
   <DQ>…</DQ>
   <InverseQ>…</InverseQ>
   <D>…</D>
</RSAKeyValue>

When you pass false to the ToXmlString method, the resulting XML string takes the following form:

<RSAKeyValue>
   <Modulus>…</Modulus>
   <Exponent>…</Exponent>
</RSAKeyValue>

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft