This documentation is archived and is not being maintained.

RSACryptoServiceProvider.ExportParameters Method

Exports the RSAParameters.

[Visual Basic]
Overrides Public Function ExportParameters( _
   ByVal includePrivateParameters As Boolean _
) As RSAParameters
[C#]
public override RSAParameters ExportParameters(
 bool includePrivateParameters
);
[C++]
public: RSAParameters ExportParameters(
 bool includePrivateParameters
);
[JScript]
public override function ExportParameters(
   includePrivateParameters : Boolean
) : RSAParameters;

Parameters

includePrivateParameters
true to include private parameters; otherwise, false.

Return Value

The parameters for RSA.

Exceptions

Exception Type Condition
CryptographicException The key cannot be exported.

Example

[Visual Basic] 
Try

    'Create a new RSACryptoServiceProvider object. 
    Dim RSA As New RSACryptoServiceProvider()

    'Export the key information to an RSAParameters object.
    'Pass false to export the public key information or pass
    'true to export public and private key information.
    Dim RSAParams As RSAParameters = RSA.ExportParameters(False)


Catch e As CryptographicException
    'Catch this exception in case the encryption did
    'not succeed.
    Console.WriteLine(e.Message)
End Try

[C#] 
try
{
    //Create a new RSACryptoServiceProvider object.
    RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();


    //Export the key information to an RSAParameters object.
    //Pass false to export the public key information or pass
    //true to export public and private key information.
    RSAParameters RSAParams = RSA.ExportParameters(false);


}
catch(CryptographicException e)
{
    //Catch this exception in case the encryption did
    //not succeed.
    Console.WriteLine(e.Message);

}

[C++] 
try {
    //Create a new RSACryptoServiceProvider Object*.
    RSACryptoServiceProvider* RSA = new RSACryptoServiceProvider();

    //Export the key information to an RSAParameters object.
    //Pass false to export the public key information or pass
    //true to export public and private key information.
    RSAParameters RSAParams = RSA->ExportParameters(false);
} catch (CryptographicException* e) {
    //Catch this exception in case the encryption did
    //not succeed.
    Console::WriteLine(e->Message);
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

RSACryptoServiceProvider Class | RSACryptoServiceProvider Members | System.Security.Cryptography Namespace | Cryptographic Services

Show: