Freigeben über


RSACryptoServiceProvider.ImportParameters-Methode

Importiert die angegebenen RSAParameters.

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

Syntax

'Declaration
Public Overrides Sub ImportParameters ( _
    parameters As RSAParameters _
)
'Usage
Dim instance As RSACryptoServiceProvider
Dim parameters As RSAParameters

instance.ImportParameters(parameters)
public override void ImportParameters (
    RSAParameters parameters
)
public:
virtual void ImportParameters (
    RSAParameters parameters
) override
public void ImportParameters (
    RSAParameters parameters
)
public override function ImportParameters (
    parameters : RSAParameters
)

Parameter

  • parameters
    Die Parameter für RSA.

Ausnahmen

Ausnahmetyp Bedingung

CryptographicException

Der CSP kann nicht ermittelt werden.

– oder –

Der parameters-Parameter weist fehlende Felder auf.

Beispiel

Im folgenden Codebeispiel werden die von einem RSAParameters-Objekt erstellten Schlüsselinformationen in ein RSACryptoServiceProvider-Objekt importiert.

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)

    'Create another RSACryptoServiceProvider object.
    Dim RSA2 As New RSACryptoServiceProvider()

    'Import the the key information from the other 
    'RSACryptoServiceProvider object.  
    RSA2.ImportParameters(RSAParams)


Catch e As CryptographicException
    'Catch this exception in case the encryption did
    'not succeed.
    Console.WriteLine(e.Message)
End Try
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);

    //Create another RSACryptoServiceProvider object.
    RSACryptoServiceProvider RSA2 = new RSACryptoServiceProvider();

    //Import the the key information from the other 
    //RSACryptoServiceProvider object.  
    RSA2.ImportParameters(RSAParams);


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

}
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 );
   
   //Create another RSACryptoServiceProvider object.
   RSACryptoServiceProvider^ RSA2 = gcnew RSACryptoServiceProvider;
   
   //Import the the key information from the other 
   //RSACryptoServiceProvider object.  
   RSA2->ImportParameters( RSAParams );
}
catch ( CryptographicException^ e ) 
{
   //Catch this exception in case the encryption did
   //not succeed.
   Console::WriteLine( e->Message );
}
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);

    // Create another RSACryptoServiceProvider object.
    RSACryptoServiceProvider rsa2 = new RSACryptoServiceProvider();

    // Import the the key information from the other 
    // RSACryptoServiceProvider object.  
    rsa2.ImportParameters(rsaParams);
}
catch (CryptographicException e) {
    // Catch this exception in case the encryption did
    // not succeed.
    Console.WriteLine(e.get_Message());
}

.NET Framework-Sicherheit

  • KeyContainerPermission  für die Berechtigung zum Importieren eines Schlüssels. Zugeordnete Enumeration: Import. Sicherheitsaktion: Demand.

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0

Siehe auch

Referenz

RSACryptoServiceProvider-Klasse
RSACryptoServiceProvider-Member
System.Security.Cryptography-Namespace

Weitere Ressourcen

Kryptografische Dienste