CspKeyContainerInfo CspKeyContainerInfo CspKeyContainerInfo CspKeyContainerInfo Class

Définition

Fournit des informations supplémentaires sur une paire de clés de chiffrement.Provides additional information about a cryptographic key pair. Cette classe ne peut pas être héritée.This class cannot be inherited.

public ref class CspKeyContainerInfo sealed
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class CspKeyContainerInfo
type CspKeyContainerInfo = class
Public NotInheritable Class CspKeyContainerInfo
Héritage
CspKeyContainerInfoCspKeyContainerInfoCspKeyContainerInfoCspKeyContainerInfo
Attributs

Exemples

L’exemple de code suivant crée un conteneur de clé et récupère des informations sur ce conteneur.The following code example creates a key container and retrieves information about that container.

using namespace System;
using namespace System::Security::Cryptography;
using namespace System::Text;
int main()
{
   RSACryptoServiceProvider^ rsa = gcnew RSACryptoServiceProvider;
   try
   {
      
      // Note: In cases where a random key is generated,   
      // a key container is not created until you call  
      // a method that uses the key.  This example calls
      // the Encrypt method before calling the
      // CspKeyContainerInfo property so that a key
      // container is created.  
      // Create some data to encrypt and display it.
      String^ data = L"Here is some data to encrypt.";
      Console::WriteLine( L"Data to encrypt: {0}", data );
      
      // Convert the data to an array of bytes and 
      // encrypt it.
      array<Byte>^byteData = Encoding::ASCII->GetBytes( data );
      array<Byte>^encData = rsa->Encrypt( byteData, false );
      
      // Display the encrypted value.
      Console::WriteLine( L"Encrypted Data: {0}", Encoding::ASCII->GetString( encData ) );
      Console::WriteLine();
      Console::WriteLine( L"CspKeyContainerInfo information:" );
      Console::WriteLine();
      
      // Create a new CspKeyContainerInfo object.
      CspKeyContainerInfo^ keyInfo = rsa->CspKeyContainerInfo;
      
      // Display the value of each property.
      Console::WriteLine( L"Accessible property: {0}", keyInfo->Accessible );
      Console::WriteLine( L"Exportable property: {0}", keyInfo->Exportable );
      Console::WriteLine( L"HardwareDevice property: {0}", keyInfo->HardwareDevice );
      Console::WriteLine( L"KeyContainerName property: {0}", keyInfo->KeyContainerName );
      Console::WriteLine( L"KeyNumber property: {0}", keyInfo->KeyNumber );
      Console::WriteLine( L"MachineKeyStore property: {0}", keyInfo->MachineKeyStore );
      Console::WriteLine( L"Protected property: {0}", keyInfo->Protected );
      Console::WriteLine( L"ProviderName property: {0}", keyInfo->ProviderName );
      Console::WriteLine( L"ProviderType property: {0}", keyInfo->ProviderType );
      Console::WriteLine( L"RandomlyGenerated property: {0}", keyInfo->RandomlyGenerated );
      Console::WriteLine( L"Removable property: {0}", keyInfo->Removable );
      Console::WriteLine( L"UniqueKeyContainerName property: {0}", keyInfo->UniqueKeyContainerName );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( e );
   }
   finally
   {
      
      // Clear the key.
      rsa->Clear();
   }

}

using System;
using System.Security.Cryptography;
using System.Text;


public class CspKeyContainerInfoExample
{

    public static void Main(String[] args)
    {
        RSACryptoServiceProvider rsa= new RSACryptoServiceProvider();

        try
        {
            // Note: In cases where a random key is generated,   
            // a key container is not created until you call  
            // a method that uses the key.  This example calls
            // the Encrypt method before calling the
            // CspKeyContainerInfo property so that a key
            // container is created.  

            // Create some data to encrypt and display it.
            string data = "Here is some data to encrypt.";

            Console.WriteLine("Data to encrypt: " + data);

            // Convert the data to an array of bytes and 
            // encrypt it.
            byte[] byteData = Encoding.ASCII.GetBytes(data);

            byte[] encData = rsa.Encrypt(byteData, false);

            // Display the encrypted value.
            Console.WriteLine("Encrypted Data: " + Encoding.ASCII.GetString(encData));

            Console.WriteLine();

            Console.WriteLine("CspKeyContainerInfo information:");

            Console.WriteLine();

            // Create a new CspKeyContainerInfo object.
            CspKeyContainerInfo keyInfo = rsa.CspKeyContainerInfo;

            // Display the value of each property.

            Console.WriteLine("Accessible property: " + keyInfo.Accessible);

            Console.WriteLine("Exportable property: " + keyInfo.Exportable);

            Console.WriteLine("HardwareDevice property: " + keyInfo.HardwareDevice);

            Console.WriteLine("KeyContainerName property: " + keyInfo.KeyContainerName);

            Console.WriteLine("KeyNumber property: " + keyInfo.KeyNumber.ToString());

            Console.WriteLine("MachineKeyStore property: " + keyInfo.MachineKeyStore);

            Console.WriteLine("Protected property: " + keyInfo.Protected);

            Console.WriteLine("ProviderName property: " + keyInfo.ProviderName);

            Console.WriteLine("ProviderType property: " + keyInfo.ProviderType);

            Console.WriteLine("RandomlyGenerated property: " + keyInfo.RandomlyGenerated);

            Console.WriteLine("Removable property: " + keyInfo.Removable);

            Console.WriteLine("UniqueKeyContainerName property: " + keyInfo.UniqueKeyContainerName);


        }
        catch (Exception e)
        {
            Console.WriteLine(e.ToString());
        }
        finally
        {
            // Clear the key.
            rsa.Clear();
        }
    }
}
Imports System
Imports System.Security.Cryptography
Imports System.Text

Module CspKeyContainerInfoExample

    Sub Main(ByVal args() As String)
        Dim rsa As New RSACryptoServiceProvider()

        Try
            ' Note: In cases where a random key is generated,   
            ' a key container is not created until you call  
            ' a method that uses the key.  This example calls
            ' the Encrypt method before calling the
            ' CspKeyContainerInfo property so that a key
            ' container is created.  
            ' Create some data to encrypt and display it.
            Dim data As String = "Here is some data to encrypt."

            Console.WriteLine("Data to encrypt: " + data)

            ' Convert the data to an array of bytes and 
            ' encrypt it.
            Dim byteData As Byte() = Encoding.ASCII.GetBytes(data)

            Dim encData As Byte() = rsa.Encrypt(byteData, False)

            ' Display the encrypted value.
            Console.WriteLine("Encrypted Data: " + Encoding.ASCII.GetString(encData))

            Console.WriteLine()

            Console.WriteLine("CspKeyContainerInfo information:")

            Console.WriteLine()

            ' Create a new CspKeyContainerInfo object.
            Dim keyInfo As CspKeyContainerInfo = rsa.CspKeyContainerInfo

            ' Display the value of each property.
            Console.WriteLine("Accessible property: " + keyInfo.Accessible.ToString())

            Console.WriteLine("Exportable property: " + keyInfo.Exportable.ToString())

            Console.WriteLine("HardwareDevice property: " + keyInfo.HardwareDevice.ToString())

            Console.WriteLine("KeyContainerName property: " + keyInfo.KeyContainerName)

            Console.WriteLine("KeyNumber property: " + keyInfo.KeyNumber.ToString())

            Console.WriteLine("MachineKeyStore property: " + keyInfo.MachineKeyStore.ToString())

            Console.WriteLine("Protected property: " + keyInfo.Protected.ToString())

            Console.WriteLine("ProviderName property: " + keyInfo.ProviderName)

            Console.WriteLine("ProviderType property: " + keyInfo.ProviderType.ToString())

            Console.WriteLine("RandomlyGenerated property: " + keyInfo.RandomlyGenerated.ToString())

            Console.WriteLine("Removable property: " + keyInfo.Removable.ToString())

            Console.WriteLine("UniqueKeyContainerName property: " + keyInfo.UniqueKeyContainerName)


        Catch e As Exception
            Console.WriteLine(e.ToString())
        Finally
            ' Clear the key.
            rsa.Clear()
        End Try
        Console.ReadLine()

    End Sub
End Module

Remarques

Utilisez cette classe pour obtenir des informations supplémentaires sur une paire de clés, telles que le nom du conteneur de clé ou le numéro de clé.Use this class to obtain additional information about a key pair, such as the key container name or the key number.

Dans les RSACryptoServiceProvider DSACryptoServiceProvidercas où une clé aléatoire est générée par ou, un conteneur de clé n’est pas créé tant que vous n’appelez pas une méthode qui utilise la clé.In cases where a random key is generated by the RSACryptoServiceProvider or the DSACryptoServiceProvider, a key container will not be created until you call a method that uses the key. Certaines propriétés de la CspKeyContainerInfo classe lèvent une CryptographicException si un conteneur de clé n’a pas été créé.Some properties of the CspKeyContainerInfo class will throw a CryptographicException if a key container has not been created.

Constructeurs

CspKeyContainerInfo(CspParameters) CspKeyContainerInfo(CspParameters) CspKeyContainerInfo(CspParameters) CspKeyContainerInfo(CspParameters)

Initialise une nouvelle instance de la classe CspKeyContainerInfo à l'aide des paramètres spécifiés.Initializes a new instance of the CspKeyContainerInfo class using the specified parameters.

Propriétés

Accessible Accessible Accessible Accessible

Obtient une valeur qui indique si une clé dans un conteneur de clé est accessible.Gets a value indicating whether a key in a key container is accessible.

CryptoKeySecurity CryptoKeySecurity CryptoKeySecurity CryptoKeySecurity

Obtient un objet CryptoKeySecurity qui représente des droits d'accès et des règles d'audit pour un conteneur.Gets a CryptoKeySecurity object that represents access rights and audit rules for a container.

Exportable Exportable Exportable Exportable

Obtient une valeur qui indique si une clé peut être exportée d'un conteneur de clé.Gets a value indicating whether a key can be exported from a key container.

HardwareDevice HardwareDevice HardwareDevice HardwareDevice

Obtient une valeur qui indique si une clé est une clé matérielle.Gets a value indicating whether a key is a hardware key.

KeyContainerName KeyContainerName KeyContainerName KeyContainerName

Obtient un nom de conteneur de clé.Gets a key container name.

KeyNumber KeyNumber KeyNumber KeyNumber

Obtient une valeur qui décrit si une clé asymétrique a été créée en tant que clé de signature ou clé d'échange.Gets a value that describes whether an asymmetric key was created as a signature key or an exchange key.

MachineKeyStore MachineKeyStore MachineKeyStore MachineKeyStore

Obtient une valeur qui indique si une clé provient d'un jeu de clés ordinateur.Gets a value indicating whether a key is from a machine key set.

Protected Protected Protected Protected

Obtient une valeur qui indique si une paire de clés est protégée.Gets a value indicating whether a key pair is protected.

ProviderName ProviderName ProviderName ProviderName

Obtient le nom de fournisseur d'une clé.Gets the provider name of a key.

ProviderType ProviderType ProviderType ProviderType

Obtient le type de fournisseur d'une clé.Gets the provider type of a key.

RandomlyGenerated RandomlyGenerated RandomlyGenerated RandomlyGenerated

Obtient une valeur qui indique si un conteneur de clé a été généré aléatoirement par une classe de chiffrement managée.Gets a value indicating whether a key container was randomly generated by a managed cryptography class.

Removable Removable Removable Removable

Obtient une valeur qui indique si une clé peut être supprimée d'un conteneur de clé.Gets a value indicating whether a key can be removed from a key container.

UniqueKeyContainerName UniqueKeyContainerName UniqueKeyContainerName UniqueKeyContainerName

Obtient un nom de conteneur de clé unique.Gets a unique key container name.

Méthodes

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Détermine si l'objet spécifié est identique à l'objet actuel.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Fait office de fonction de hachage par défaut.Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Obtient le Type de l'instance actuelle.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Crée une copie superficielle de l'objet Object actuel.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Retourne une chaîne qui représente l'objet actuel.Returns a string that represents the current object.

(Inherited from Object)

S’applique à