CspParameters-Konstruktor (Int32)
Initialisiert eine neue Instanz der CspParameters-Klasse mit dem angegebenen Anbietertypcode.
Namespace: System.Security.Cryptography
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public Sub New ( _
dwTypeIn As Integer _
)
'Usage
Dim dwTypeIn As Integer
Dim instance As New CspParameters(dwTypeIn)
public CspParameters (
int dwTypeIn
)
public:
CspParameters (
int dwTypeIn
)
public CspParameters (
int dwTypeIn
)
public function CspParameters (
dwTypeIn : int
)
Parameter
- dwTypeIn
Ein Anbietertypcode, der die Art des zu erstellenden Anbieters angibt.
Hinweise
Mit dem CspParameters-Konstruktor können Sie einen Anbietertyp angeben, indem Sie einen numerischen Wert übergeben, der diesen Anbieter darstellt. Die numerischen Werte, die die Standardanbietertypen darstellen, sind in der Headerdatei WinCrypt.h definiert:
Übergeben Sie den Wert 1 an den dwTypeIn-Parameter, um einen mit dem RSA-Algorithmus kompatiblen Anbieter anzugeben.
Übergeben Sie den Wert 13 an den dwTypeIn-Parameter, um einen mit dem DSA-Algorithmus kompatiblen Anbieter anzugeben.
Informationen zu anderen Anbietertypwerten finden Sie im ProviderType-Feld. Weitere Informationen zu den Standardanbietertypen und ihrem Verhalten finden Sie in der Dokumentation zur Microsoft Cryptography API (CAPI) in der MSDN Library.
Beispiel
Im folgenden Codebeispiel wird ein Schlüsselcontainer unter Verwendung der CspParameters-Klasse erstellt und der Schlüssel im Container gespeichert.
Imports System
Imports System.IO
Imports System.Security.Cryptography
Public Class StoreKey
Public Shared Sub Main()
' creates the CspParameters object and sets the key container name used to store the RSA key pair
Dim cp As New CspParameters()
cp.KeyContainerName = "MyKeyContainerName"
' instantiates the rsa instance accessing the key container MyKeyContainerName
Dim rsa As New RSACryptoServiceProvider(cp)
' add the below line to delete the key entry in MyKeyContainerName
' rsa.PersistKeyInCsp = false;
'writes out the current key pair used in the rsa instance
Console.WriteLine("Key is : " & rsa.ToXmlString(True))
End Sub 'Main
End Class 'StoreKey
using System;
using System.IO;
using System.Security.Cryptography;
public class StoreKey
{
public static void Main()
{
// creates the CspParameters object and sets the key container name used to store the RSA key pair
CspParameters cp = new CspParameters();
cp.KeyContainerName = "MyKeyContainerName";
// instantiates the rsa instance accessing the key container MyKeyContainerName
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(cp);
// add the below line to delete the key entry in MyKeyContainerName
// rsa.PersistKeyInCsp = false;
//writes out the current key pair used in the rsa instance
Console.WriteLine("Key is : \n" + rsa.ToXmlString(true));
}
}
using namespace System;
using namespace System::IO;
using namespace System::Security::Cryptography;
int main()
{
// creates the CspParameters object and sets the key container name used to store the RSA key pair
CspParameters^ cp = gcnew CspParameters;
cp->KeyContainerName = "MyKeyContainerName";
// instantiates the rsa instance accessing the key container MyKeyContainerName
RSACryptoServiceProvider^ rsa = gcnew RSACryptoServiceProvider( cp );
// add the below line to delete the key entry in MyKeyContainerName
// rsa.PersistKeyInCsp = false;
//writes out the current key pair used in the rsa instance
Console::WriteLine( "Key is : \n{0}", rsa->ToXmlString( true ) );
}
import System.*;
import System.IO.*;
import System.Security.Cryptography.*;
public class StoreKey
{
public static void main(String[] args)
{
// creates the CspParameters object and sets the key container name
// used to store the RSA key pair
CspParameters cp = new CspParameters();
cp.KeyContainerName = "MyKeyContainerName";
// instantiates the rsa instance accessing the key container
// MyKeyContainerName
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(cp);
// add the below line to delete the key entry in MyKeyContainerName
// rsa.PersistKeyInCsp = false;
//writes out the current key pair used in the rsa instance
Console.WriteLine("Key is : \n" + rsa.ToXmlString(true));
} //main
} //StoreKey
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
CspParameters-Klasse
CspParameters-Member
System.Security.Cryptography-Namespace