CspParameters.KeyContainerName-Feld
Stellt den Schlüsselcontainernamen für CspParameters dar.
Namespace: System.Security.Cryptography
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public KeyContainerName As String
'Usage
Dim instance As CspParameters
Dim value As String
value = instance.KeyContainerName
instance.KeyContainerName = value
public string KeyContainerName
public:
String^ KeyContainerName
public String KeyContainerName
public var KeyContainerName : String
Hinweise
Geben Sie unter Verwendung des KeyContainerName-Felds einen Namen für den Schlüsselcontainer an. Sie können den Containernamen verwenden, um den beibehaltenen Schlüssel innerhalb dieses Containers abzurufen.
Weitere Informationen zum Erstellen von Schlüsselcontainern finden Sie unter Gewusst wie: Speichern von asymmetrischen Schlüsseln in einem Schlüsselcontainer.
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