CngKey.Exists 方法

定義

檢查特定金鑰儲存提供者 (KSP) 中是否有具名金鑰。Checks for a named key in a specific key storage provider(KSP).

多載

Exists(String, CngProvider, CngKeyOpenOptions)

根據指定的選項,查看具名金鑰是否存在指定的金鑰儲存提供者 (KSP) 中。Checks to see whether a named key exists in the specified key storage provider (KSP), according to the specified options.

Exists(String)

查看具名金鑰是否存在預設的金鑰儲存提供者 (KSP) 中。Checks to see whether a named key exists in the default key storage provider (KSP).

Exists(String, CngProvider)

查看具名金鑰是否存在指定的金鑰儲存提供者 (KSP) 中。Checks to see whether a named key exists in the specified key storage provider (KSP).

Exists(String, CngProvider, CngKeyOpenOptions)

根據指定的選項,查看具名金鑰是否存在指定的金鑰儲存提供者 (KSP) 中。Checks to see whether a named key exists in the specified key storage provider (KSP), according to the specified options.

public:
 static bool Exists(System::String ^ keyName, System::Security::Cryptography::CngProvider ^ provider, System::Security::Cryptography::CngKeyOpenOptions options);
public static bool Exists (string keyName, System.Security.Cryptography.CngProvider provider, System.Security.Cryptography.CngKeyOpenOptions options);
[System.Security.SecurityCritical]
public static bool Exists (string keyName, System.Security.Cryptography.CngProvider provider, System.Security.Cryptography.CngKeyOpenOptions options);
static member Exists : string * System.Security.Cryptography.CngProvider * System.Security.Cryptography.CngKeyOpenOptions -> bool
[<System.Security.SecurityCritical>]
static member Exists : string * System.Security.Cryptography.CngProvider * System.Security.Cryptography.CngKeyOpenOptions -> bool
Public Shared Function Exists (keyName As String, provider As CngProvider, options As CngKeyOpenOptions) As Boolean

參數

keyName
String

索引鍵名稱。The key name.

provider
CngProvider

要在其中搜尋是否有金鑰的 KSP。The KSP to search for the key.

options
CngKeyOpenOptions

列舉型別值的位元組合,指定開啟金鑰的選項。A bitwise combination of the enumeration values that specify options for opening a key.

傳回

Boolean

如果具名金鑰存在指定的提供者中,則為 true,否則為 falsetrue if the named key exists in the specified provider; otherwise, false.

屬性

例外狀況

keyNameprovidernullkeyName or provider is null.

此系統不支援新一代密碼編譯 (CNG)。Cryptography Next Generation (CNG) is not supported on this system.

所有其他錯誤。All other errors.

備註

您可以使用此多載來檢查預設值以外的 KSP 是否存在金鑰 MicrosoftSoftwareKeyStorageProvider ,並指定索引鍵開啟選項。Use this overload to check for the existence of a key in a KSP other than the default MicrosoftSoftwareKeyStorageProvider, and to specify key open options.

適用於

Exists(String)

查看具名金鑰是否存在預設的金鑰儲存提供者 (KSP) 中。Checks to see whether a named key exists in the default key storage provider (KSP).

public:
 static bool Exists(System::String ^ keyName);
public static bool Exists (string keyName);
static member Exists : string -> bool
Public Shared Function Exists (keyName As String) As Boolean

參數

keyName
String

索引鍵名稱。The key name.

傳回

Boolean

如果具名金鑰存在預設的 KSP 中,則為 true,否則為 falsetrue if the named key exists in the default KSP; otherwise, false.

例外狀況

keyNamenullkeyName is null.

此系統不支援新一代密碼編譯 (CNG)。Cryptography Next Generation (CNG) is not supported on this system.

所有其他錯誤。All other errors.

備註

預設 KSP 為 MicrosoftSoftwareKeyStorageProviderThe default KSP is MicrosoftSoftwareKeyStorageProvider.

適用於

Exists(String, CngProvider)

查看具名金鑰是否存在指定的金鑰儲存提供者 (KSP) 中。Checks to see whether a named key exists in the specified key storage provider (KSP).

public:
 static bool Exists(System::String ^ keyName, System::Security::Cryptography::CngProvider ^ provider);
public static bool Exists (string keyName, System.Security.Cryptography.CngProvider provider);
static member Exists : string * System.Security.Cryptography.CngProvider -> bool
Public Shared Function Exists (keyName As String, provider As CngProvider) As Boolean

參數

keyName
String

索引鍵名稱。The key name.

provider
CngProvider

要檢查其中是否有金鑰的 KSP。The KSP to check for the key.

傳回

Boolean

如果具名金鑰存在指定的提供者中,則為 true,否則為 falsetrue if the named key exists in the specified provider; otherwise, false.

例外狀況

keyNameprovidernullkeyName or provider is null.

此系統不支援新一代密碼編譯 (CNG)。Cryptography Next Generation (CNG) is not supported on this system.

所有其他錯誤。All other errors.

備註

您可以使用此多載來檢查預設 KSP 以外的 KSP 是否存在金鑰,也就是 MicrosoftSoftwareKeyStorageProviderUse this overload to check for the existence of a key in a KSP other than the default KSP, which is MicrosoftSoftwareKeyStorageProvider.

適用於