CryptoConfig.CreateFromName Method

Definition

Creates a new instance of the specified cryptographic object.

Overloads

CreateFromName(String)

Creates a new instance of the specified cryptographic object.

CreateFromName(String, Object[])

Creates a new instance of the specified cryptographic object with the specified arguments.

CreateFromName(String)

Source:
CryptoConfig.cs
Source:
CryptoConfig.cs
Source:
CryptoConfig.cs

Creates a new instance of the specified cryptographic object.

C#
public static object? CreateFromName(string name);
C#
public static object CreateFromName(string name);

Parameters

name
String

The simple name of the cryptographic object of which to create an instance.

Returns

A new instance of the specified cryptographic object.

Exceptions

The name parameter is null.

The algorithm described by the name parameter was used with Federal Information Processing Standards (FIPS) mode enabled, but is not FIPS compatible.

Examples

The following code example demonstrates how to call the CreateFromName method to create a new SHA1 provider. This code example is part of a larger example provided for the CryptoConfig class.

C#
// This example uses the SHA1 algorithm.
// Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
SHA1CryptoServiceProvider SHA1alg = 
    (SHA1CryptoServiceProvider)CryptoConfig.CreateFromName("SHA1");

Remarks

For a list of simple names recognized by this class, see CryptoConfig.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 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

CreateFromName(String, Object[])

Source:
CryptoConfig.cs
Source:
CryptoConfig.cs
Source:
CryptoConfig.cs

Creates a new instance of the specified cryptographic object with the specified arguments.

C#
public static object? CreateFromName(string name, params object?[]? args);
C#
public static object CreateFromName(string name, params object[] args);
C#
public static object CreateFromName(string name, object[] args);

Parameters

name
String

The simple name of the cryptographic object of which to create an instance.

args
Object[]

The arguments used to create the specified cryptographic object.

Returns

A new instance of the specified cryptographic object.

Exceptions

The name parameter is null.

The algorithm described by the name parameter was used with Federal Information Processing Standards (FIPS) mode enabled, but is not FIPS compatible.

Examples

The following code example demonstrates how to call the CreateFromName method to initialize a new RSA provider instance accessing the TestContainer key container. This code example is part of a larger example provided for the CryptoConfig class.

C#
CspParameters parameters = new CspParameters();
parameters.KeyContainerName = "TestContainer";
Object[] argsArray = new Object[] {parameters};

// Instantiate the RSA provider instance accessing the TestContainer
// key container.
RSA rsa = (RSA)
    CryptoConfig.CreateFromName("RSA",argsArray);

Remarks

For a list of simple names recognized by this class, see CryptoConfig.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 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