CngKey.Create CngKey.Create CngKey.Create CngKey.Create Method

Definition

Creates a CngKey object that represents a new key.

Overloads

Create(CngAlgorithm) Create(CngAlgorithm) Create(CngAlgorithm) Create(CngAlgorithm)

Creates a CngKey object that can be used with the specified algorithm.

Create(CngAlgorithm, String) Create(CngAlgorithm, String) Create(CngAlgorithm, String) Create(CngAlgorithm, String)

Creates a named CngKey object that provides the specified algorithm.

Create(CngAlgorithm, String, CngKeyCreationParameters) Create(CngAlgorithm, String, CngKeyCreationParameters) Create(CngAlgorithm, String, CngKeyCreationParameters) Create(CngAlgorithm, String, CngKeyCreationParameters)

Creates a named CngKey object that provides the specified algorithm, using the supplied key creation parameters.

Create(CngAlgorithm) Create(CngAlgorithm) Create(CngAlgorithm) Create(CngAlgorithm)

Creates a CngKey object that can be used with the specified algorithm.

public:
 static System::Security::Cryptography::CngKey ^ Create(System::Security::Cryptography::CngAlgorithm ^ algorithm);
public static System.Security.Cryptography.CngKey Create (System.Security.Cryptography.CngAlgorithm algorithm);
static member Create : System.Security.Cryptography.CngAlgorithm -> System.Security.Cryptography.CngKey
Public Shared Function Create (algorithm As CngAlgorithm) As CngKey

Parameters

algorithm
CngAlgorithm CngAlgorithm CngAlgorithm CngAlgorithm

The algorithm that the key will be used with.

Returns

An ephemeral key.

Exceptions

Remarks

This overload creates a key without a name, which means that the key is ephemeral (that is, it will not be persisted). It also creates a default CngKeyCreationParameters object that specifies a default CngProvider and other advanced parameters for the key.

Security

KeyContainerPermissionAccessEntryCollection
for permission to create a key container. Demand value: Demand. Associated enumeration: Create

Create(CngAlgorithm, String) Create(CngAlgorithm, String) Create(CngAlgorithm, String) Create(CngAlgorithm, String)

Creates a named CngKey object that provides the specified algorithm.

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);
static member Create : System.Security.Cryptography.CngAlgorithm * string -> System.Security.Cryptography.CngKey
Public Shared Function Create (algorithm As CngAlgorithm, keyName As String) As CngKey

Parameters

algorithm
CngAlgorithm CngAlgorithm CngAlgorithm CngAlgorithm

The algorithm that the key will be used with.

keyName
String String String String

The key name. If a name is not provided, the key will not be persisted.

Returns

A persisted or ephemeral key that provides the specified algorithm.

Exceptions

Remarks

If keyName is provided, this overload creates a persisted key. If keyName is not provided, the key will be ephemeral. This overload also creates a default CngKeyCreationParameters object that specifies a default CngProvider and other advanced parameters for the key.

Security

KeyContainerPermissionAccessEntryCollection
for permission to create a key container. Demand value: Demand. Associated enumeration: Create

Create(CngAlgorithm, String, CngKeyCreationParameters) Create(CngAlgorithm, String, CngKeyCreationParameters) Create(CngAlgorithm, String, CngKeyCreationParameters) Create(CngAlgorithm, String, CngKeyCreationParameters)

Creates a named CngKey object that provides the specified algorithm, using the supplied key creation parameters.

public:
 static System::Security::Cryptography::CngKey ^ Create(System::Security::Cryptography::CngAlgorithm ^ algorithm, System::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
Public Shared Function Create (algorithm As CngAlgorithm, keyName As String, creationParameters As CngKeyCreationParameters) As CngKey

Parameters

algorithm
CngAlgorithm CngAlgorithm CngAlgorithm CngAlgorithm

The algorithm that the key will be used with.

keyName
String String String String

The key name. If a name is not provided, the key will not be persisted.

creationParameters
CngKeyCreationParameters CngKeyCreationParameters CngKeyCreationParameters CngKeyCreationParameters

An object that specifies advanced parameters for the method, including the CngProvider.

Returns

A persisted or ephemeral key that provides the specified algorithm.

Exceptions

Remarks

If keyName is provided, this overload creates a persisted key. If keyName is not provided, the key will be ephemeral.

Security

KeyContainerPermissionAccessEntryCollection
for permission to create a key container. Demand value: Demand. Associated enumeration: Create

Applies to