KeyNumber 列舉

定義

指定要建立非對稱簽章金鑰或非對稱交換金鑰。Specifies whether to create an asymmetric signature key or an asymmetric exchange key.

public enum class KeyNumber
public enum KeyNumber
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public enum KeyNumber
type KeyNumber = 
Public Enum KeyNumber
繼承
KeyNumber
屬性

欄位

Exchange 1

交換金鑰組,可用來加密工作階段金鑰,使其能安全地儲存並與其他使用者交換。An exchange key pair used to encrypt session keys so that they can be safely stored and exchanged with other users. 此值對應到非受控 Microsoft Cryptographic API (CAPI) 中使用的 AT_KEYEXCHANGE 值。This value corresponds to the AT_KEYEXCHANGE value used in the unmanaged Microsoft Cryptographic API (CAPI).

Signature 2

簽章金鑰組,可用來驗證數位簽署的訊息或檔案。A signature key pair used for authenticating digitally signed messages or files. 此值對應到非受控 Microsoft Cryptographic API (CAPI) 中使用的 AT_SIGNATURE 值。This value corresponds to the AT_SIGNATURE value used in the unmanaged Microsoft Cryptographic API (CAPI).

範例

下列程式碼範例示範如何使用 KeyNumber 列舉來指定 RSACryptoServiceProvider 物件的索引鍵類型。The following code example demonstrates how to use the KeyNumber enumeration to specify a key type for an RSACryptoServiceProvider object.

// Create a new CspParameters object.
CspParameters^ cspParams = gcnew CspParameters();

// Specify an exchange key.
cspParams->KeyNumber = (int) KeyNumber::Exchange;

// Initialize the RSACryptoServiceProvider
// with the CspParameters object.
RSACryptoServiceProvider^ RSACSP = gcnew RSACryptoServiceProvider(cspParams);
// Create a new CspParameters object.
CspParameters cspParams = new CspParameters();

// Specify an exchange key.
cspParams.KeyNumber = (int) KeyNumber.Exchange;

// Initialize the RSACryptoServiceProvider  
// with the CspParameters object.
RSACryptoServiceProvider RSACSP = new RSACryptoServiceProvider(cspParams);
' Create a new CspParameters object.
Dim cspParams As New CspParameters()

' Specify an exchange key.
cspParams.KeyNumber = Fix(KeyNumber.Exchange)

' Initialize the RSACryptoServiceProvider  
' with the CspParameters object.
Dim RSACSP As New RSACryptoServiceProvider(cspParams)

備註

使用具有 CspKeyContainerInfo.KeyNumber 屬性的 KeyNumber 列舉來檢查索引鍵類型,或利用 CspParameters.KeyNumber 欄位來指定金鑰類型。Use the KeyNumber enumeration with the CspKeyContainerInfo.KeyNumber property to inspect a key type or with the CspParameters.KeyNumber field to specify a key type.

適用於