RSACryptoServiceProvider.ImportParameters(RSAParameters) Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Importiert die angegebene RSAParameters.
public:
override void ImportParameters(System::Security::Cryptography::RSAParameters parameters);
public override void ImportParameters(System.Security.Cryptography.RSAParameters parameters);
override this.ImportParameters : System.Security.Cryptography.RSAParameters -> unit
Public Overrides Sub ImportParameters (parameters As RSAParameters)
Parameter
- parameters
- RSAParameters
Die Parameter für RSA.
Ausnahmen
Der kryptografische Dienstanbieter (CSP) kann nicht erworben werden.
-oder-
Der parameters Parameter enthält fehlende Felder.
Beispiele
Im folgenden Codebeispiel werden schlüsselinformationen importiert, die aus einem RSAParameters Objekt erstellt wurden, in ein RSACryptoServiceProvider Objekt.
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);
//Create another RSACryptoServiceProvider object.
using (RSACryptoServiceProvider RSA2 = new RSACryptoServiceProvider())
{
//Import 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.
Using 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.
Using RSA2 As New RSACryptoServiceProvider()
'Import the key information from the other
'RSACryptoServiceProvider object.
RSA2.ImportParameters(RSAParams)
End Using
End Using
Catch e As CryptographicException
'Catch this exception in case the encryption did
'not succeed.
Console.WriteLine(e.Message)
End Try