CngKey.Create 方法

定义

创建一个表示新密钥的 CngKey 对象。

重载

Create(CngAlgorithm)

创建一个可以与指定算法一起使用的 CngKey 对象。

Create(CngAlgorithm, String)

创建一个已命名的 CngKey 对象,该对象提供指定的算法。

Create(CngAlgorithm, String, CngKeyCreationParameters)

使用所提供的密钥创建参数,创建一个已命名的 CngKey 对象,该对象提供指定的算法。

Create(CngAlgorithm)

创建一个可以与指定算法一起使用的 CngKey 对象。

public:
 static System::Security::Cryptography::CngKey ^ Create(System::Security::Cryptography::CngAlgorithm ^ algorithm);
public static System.Security.Cryptography.CngKey Create (System.Security.Cryptography.CngAlgorithm algorithm);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static System.Security.Cryptography.CngKey Create (System.Security.Cryptography.CngAlgorithm algorithm);
static member Create : System.Security.Cryptography.CngAlgorithm -> System.Security.Cryptography.CngKey
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member Create : System.Security.Cryptography.CngAlgorithm -> System.Security.Cryptography.CngKey
Public Shared Function Create (algorithm As CngAlgorithm) As CngKey

参数

algorithm
CngAlgorithm

将与密钥一起使用的算法。

返回

CngKey

一个暂时的密钥。

属性

例外

algorithmnull

此系统上不支持下一代加密技术 (CNG)。

所有其他错误。

注解

此重载创建一个没有名称的键,这意味着密钥是临时 (,也就是说,它不会保留) 。 它还创建一个默认 CngKeyCreationParameters 对象,该对象指定键的默认 CngProvider 参数和其他高级参数。

适用于

Create(CngAlgorithm, String)

创建一个已命名的 CngKey 对象,该对象提供指定的算法。

public:
 static System::Security::Cryptography::CngKey ^ Create(System::Security::Cryptography::CngAlgorithm ^ algorithm, System::String ^ keyName);
public static System.Security.Cryptography.CngKey Create (System.Security.Cryptography.CngAlgorithm algorithm, string keyName);
public static System.Security.Cryptography.CngKey Create (System.Security.Cryptography.CngAlgorithm algorithm, string? keyName);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static System.Security.Cryptography.CngKey Create (System.Security.Cryptography.CngAlgorithm algorithm, string? keyName);
static member Create : System.Security.Cryptography.CngAlgorithm * string -> System.Security.Cryptography.CngKey
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member Create : System.Security.Cryptography.CngAlgorithm * string -> System.Security.Cryptography.CngKey
Public Shared Function Create (algorithm As CngAlgorithm, keyName As String) As CngKey

参数

algorithm
CngAlgorithm

将与密钥一起使用的算法。

keyName
String

键名称。 如果未提供名称,则密钥将不是持久的。

返回

CngKey

提供指定算法的持久或暂时的密钥。

属性

例外

algorithmnull

此系统上不支持下一代加密技术 (CNG)。

所有其他错误。

注解

如果 keyName 提供,此重载将创建持久密钥。 如果未 keyName 提供,密钥将是临时密钥。 此重载还创建一个默认 CngKeyCreationParameters 对象,该对象指定键的默认 CngProvider 参数和其他高级参数。

适用于

Create(CngAlgorithm, String, CngKeyCreationParameters)

使用所提供的密钥创建参数,创建一个已命名的 CngKey 对象,该对象提供指定的算法。

public:
 static System::Security::Cryptography::CngKey ^ Create(System::Security::Cryptography::CngAlgorithm ^ algorithm, System::String ^ keyName, System::Security::Cryptography::CngKeyCreationParameters ^ creationParameters);
public static System.Security.Cryptography.CngKey Create (System.Security.Cryptography.CngAlgorithm algorithm, string keyName, System.Security.Cryptography.CngKeyCreationParameters creationParameters);
public static System.Security.Cryptography.CngKey Create (System.Security.Cryptography.CngAlgorithm algorithm, string? keyName, System.Security.Cryptography.CngKeyCreationParameters? creationParameters);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static System.Security.Cryptography.CngKey Create (System.Security.Cryptography.CngAlgorithm algorithm, string? keyName, System.Security.Cryptography.CngKeyCreationParameters? creationParameters);
[System.Security.SecurityCritical]
public static System.Security.Cryptography.CngKey Create (System.Security.Cryptography.CngAlgorithm algorithm, string keyName, System.Security.Cryptography.CngKeyCreationParameters creationParameters);
static member Create : System.Security.Cryptography.CngAlgorithm * string * System.Security.Cryptography.CngKeyCreationParameters -> System.Security.Cryptography.CngKey
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member Create : System.Security.Cryptography.CngAlgorithm * string * System.Security.Cryptography.CngKeyCreationParameters -> System.Security.Cryptography.CngKey
[<System.Security.SecurityCritical>]
static member Create : System.Security.Cryptography.CngAlgorithm * string * System.Security.Cryptography.CngKeyCreationParameters -> System.Security.Cryptography.CngKey
Public Shared Function Create (algorithm As CngAlgorithm, keyName As String, creationParameters As CngKeyCreationParameters) As CngKey

参数

algorithm
CngAlgorithm

将与密钥一起使用的算法。

keyName
String

键名称。 如果未提供名称,则密钥将不是持久的。

creationParameters
CngKeyCreationParameters

一个指定方法的高级参数(包括 CngProvider)的对象。

返回

CngKey

提供指定算法的持久或暂时的密钥。

属性

例外

algorithmnull

此系统上不支持下一代加密技术 (CNG)。

所有其他错误。

注解

如果 keyName 提供,此重载将创建持久密钥。 如果未 keyName 提供,密钥将是临时密钥。

适用于