RSACryptoServiceProvider.ExportParameters(Boolean) 方法

定义

导出 RSAParameters

public:
 override System::Security::Cryptography::RSAParameters ExportParameters(bool includePrivateParameters);
public override System.Security.Cryptography.RSAParameters ExportParameters (bool includePrivateParameters);
override this.ExportParameters : bool -> System.Security.Cryptography.RSAParameters
Public Overrides Function ExportParameters (includePrivateParameters As Boolean) As RSAParameters

参数

includePrivateParameters
Boolean

若要包含专用参数,则为 true;否则为 false

返回

RSA 的参数。

例外

密钥无法导出。

示例

下面的代码示例将使用 RSACryptoServiceProvider 创建的关键信息导出到 对象 RSAParameters 中。

try
{
   //Create a new RSACryptoServiceProvider Object*.
   RSACryptoServiceProvider^ RSA = gcnew 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 );
}
try
{
    //Create a new RSACryptoServiceProvider object.
    using (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);
}
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

适用于

另请参阅