Show / Hide Table of Contents

Method Hash.Crypto(+ 3 overloads)


Overload

Computes data hash using the specified cryptographic algorithm.

public static byte[] Crypto(ReadOnlySpan<byte> data, string algorithm)
Parameters
data  (ReadOnlySpan<byte>)

Data. See also: System.Runtime.InteropServices.MemoryMarshal.AsBytes<T>, System.Runtime.InteropServices.CollectionsMarshal.AsSpan<T>.

algorithm  (string)

Algorithm name, eg "SHA256". See System.Security.Cryptography.CryptoConfig.

Returns
byte[]

Overload(next)

Computes hash of string converted to UTF-8, using the specified cryptographic algorithm.

public static byte[] Crypto(string data, string algorithm)
Parameters
data  (string)
algorithm  (string)

Algorithm name, eg "SHA256". See System.Security.Cryptography.CryptoConfig.

Returns
byte[]

Overload(next)

Computes data hash using the specified cryptographic algorithm. Returns result as hex or base64 string.

public static string Crypto(ReadOnlySpan<byte> data, string algorithm, bool base64)
Parameters
data  (ReadOnlySpan<byte>)

Data. See also: System.Runtime.InteropServices.MemoryMarshal.AsBytes<T>, System.Runtime.InteropServices.CollectionsMarshal.AsSpan<T>.

algorithm  (string)

Algorithm name, eg "SHA256". See System.Security.Cryptography.CryptoConfig.

base64  (bool)
Returns
string

Overload(top)

Computes hash of string converted to UTF-8, using the specified cryptographic algorithm. Returns result as hex or base64 string.

public static string Crypto(string data, string algorithm, bool base64)
Parameters
data  (string)
algorithm  (string)

Algorithm name, eg "SHA256". See System.Security.Cryptography.CryptoConfig.

base64  (bool)
Returns
string