KeyNumber 列舉

定義

指定要建立非對稱簽章金鑰或非對稱交換金鑰。

C#
public enum KeyNumber
C#
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public enum KeyNumber
繼承
KeyNumber
屬性

欄位

名稱 Description
Exchange 1

交換金鑰組,可用來加密工作階段金鑰,使其能安全地儲存並與其他使用者交換。 此值對應到非受控 Microsoft Cryptographic API (CAPI) 中使用的 AT_KEYEXCHANGE 值。

Signature 2

簽章金鑰組,可用來驗證數位簽署的訊息或檔案。 此值對應到非受控 Microsoft Cryptographic API (CAPI) 中使用的 AT_SIGNATURE 值。

範例

下列程式代碼範例示範如何使用 KeyNumber 列舉來指定物件的索引鍵類型 RSACryptoServiceProvider

C#
// 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);

備註

KeyNumber使用 列舉搭配 CspKeyContainerInfo.KeyNumber 屬性來檢查索引鍵類型,或使用 CspParameters.KeyNumber 欄位來指定索引鍵類型。

適用於

產品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1