SHA256.Create Method

Definition

Allows specific implementations of this abstract class to be instantiated.

Overloads

Create()

Creates an instance of the default implementation of SHA256.

Create(String)
Obsolete.

Creates an instance of a specified implementation of SHA256.

Create()

Source:
SHA256.cs
Source:
SHA256.cs
Source:
SHA256.cs

Creates an instance of the default implementation of SHA256.

C#
public static System.Security.Cryptography.SHA256 Create();

Returns

A new instance of SHA256. On the .NET Framework, this method creates an instance of the SHA256Managed class if FIPS mode is not active; if FIPS mode is active, it creates an instance of the SHA256Cng class. On .NET Core, it returns an instance of a private class derived from SHA256.

Exceptions

On the .NET Framework 4.6.1 and earlier versions only: The algorithm was used with Federal Information Processing Standards (FIPS) mode enabled, but is not FIPS compatible.

See also

Applies to

.NET 9 and other versions
Product Versions
.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
.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 1.3, 1.4, 1.6, 2.0, 2.1

Create(String)

Source:
SHA256.cs
Source:
SHA256.cs
Source:
SHA256.cs

Caution

Cryptographic factory methods accepting an algorithm name are obsolete. Use the parameterless Create factory method on the algorithm type instead.

Creates an instance of a specified implementation of SHA256.

C#
public static System.Security.Cryptography.SHA256? Create(string hashName);
C#
[System.Obsolete("Cryptographic factory methods accepting an algorithm name are obsolete. Use the parameterless Create factory method on the algorithm type instead.", DiagnosticId="SYSLIB0045", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public static System.Security.Cryptography.SHA256? Create(string hashName);
C#
public static System.Security.Cryptography.SHA256 Create(string hashName);

Parameters

hashName
String

The name of the specific implementation of SHA256 to be used.

Returns

A new instance of SHA256 using the specified implementation.

Attributes

Exceptions

On the .NET Framework only: FIPS mode is enabled, but hashName requests SHA256Managed, which is not FIPS compatible.

Remarks

The .NET Framework includes the implementations and their associated hashName values:

Implementation hashName
SHA256Managed SHA256
SHA-256
System.Security.Cryptography.SHA256
SHA256Cng System.Security.Cryptography.SHA256Cng
SHA256CryptoServiceProvider System.Security.Cryptography.SHA256CryptoServiceProvider

See also

Applies to

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