CspKeyContainerInfo 클래스

정의

암호화 키 쌍에 대한 추가 정보를 제공합니다. 이 클래스는 상속될 수 없습니다.

public ref class CspKeyContainerInfo sealed
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public sealed class CspKeyContainerInfo
public sealed class CspKeyContainerInfo
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class CspKeyContainerInfo
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
type CspKeyContainerInfo = class
type CspKeyContainerInfo = class
[<System.Runtime.InteropServices.ComVisible(true)>]
type CspKeyContainerInfo = class
Public NotInheritable Class CspKeyContainerInfo
상속
CspKeyContainerInfo
특성

예제

다음 코드 예제에서는 키 컨테이너를 만들고 해당 컨테이너에 대한 정보를 검색합니다.

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.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

설명

키 컨테이너 이름 또는 키 번호와 같은 키 쌍에 대한 추가 정보를 가져오려면 이 클래스를 사용합니다.

임의 키가 생성 RSACryptoServiceProvider DSACryptoServiceProvider되는 경우 키를 사용하는 메서드를 호출할 때까지 키 컨테이너가 만들어지지 않습니다. 키 컨테이너가 CspKeyContainerInfo 만들어지지 않은 경우 클래스의 일부 속성이 throw CryptographicException 됩니다.

생성자

CspKeyContainerInfo(CspParameters)

지정된 매개 변수를 사용하여 CspKeyContainerInfo 클래스의 새 인스턴스를 초기화합니다.

속성

Accessible

키 컨테이너에 있는 키에 액세스할 수 있는지 여부를 나타내는 값을 가져옵니다.

CryptoKeySecurity

컨테이너에 대한 액세스 권한과 감사 규칙을 나타내는 CryptoKeySecurity 개체를 가져옵니다.

Exportable

키 컨테이너에서 키를 내보낼 수 있는지 여부를 나타내는 값을 가져옵니다.

HardwareDevice

키가 하드웨어 키인지 여부를 나타내는 값을 가져옵니다.

KeyContainerName

키 컨테이너 이름을 가져옵니다.

KeyNumber

비대칭 키가 서명 키로 만들어졌는지 또는 교환 키로 만들어졌는지를 설명하는 값을 가져옵니다.

MachineKeyStore

키가 컴퓨터 키 집합에 속한 키인지 여부를 나타내는 값을 가져옵니다.

Protected

키 쌍이 보호되는지 여부를 나타내는 값을 가져옵니다.

ProviderName

키의 공급자 이름을 가져옵니다.

ProviderType

키의 공급자 형식을 가져옵니다.

RandomlyGenerated

키 컨테이너가 관리되는 암호화 클래스에서 무작위로 생성되었는지 여부를 나타내는 값을 가져옵니다.

Removable

키 컨테이너에서 키를 제거할 수 있는지 여부를 나타내는 값을 가져옵니다.

UniqueKeyContainerName

고유 키 컨테이너 이름을 가져옵니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상