Class Hasher
Use this class to compute a hash in MD4, SHA1, SHA256 or SHA512.
Inherited Members
Namespace: Swan.Cryptography
Syntax
public static class Hasher
Methods
ComputeMD5(Stream, Boolean)
Computes the MD5 hash of the given stream. Do not use for large streams as this reads ALL bytes at once.
Declaration
public static byte[] ComputeMD5(Stream this, bool createHasher = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | this | The stream. |
| Boolean | createHasher | if set to |
Returns
| Type | Description |
|---|---|
| Byte[] | The computed hash code. |
ComputeMD5(Byte[], Boolean)
Computes the MD5 hash of the given byte array.
Declaration
public static byte[] ComputeMD5(byte[] data, bool createHasher = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | data | The data. |
| Boolean | createHasher | if set to |
Returns
| Type | Description |
|---|---|
| Byte[] | The computed hash code. |
ComputeMD5(String, Boolean)
Computes the MD5 hash of the given string using UTF8 byte encoding.
Declaration
public static byte[] ComputeMD5(string value, bool createHasher = false)
Parameters
| Type | Name | Description |
|---|---|---|
| String | value | The input string. |
| Boolean | createHasher | if set to |
Returns
| Type | Description |
|---|---|
| Byte[] | The computed hash code. |
ComputeSha1(String, Boolean)
Computes the SHA-1 hash of the given string using UTF8 byte encoding.
Declaration
public static byte[] ComputeSha1(string this, bool createHasher = false)
Parameters
| Type | Name | Description |
|---|---|---|
| String | this | The input string. |
| Boolean | createHasher | if set to |
Returns
| Type | Description |
|---|---|
| Byte[] | The computes a Hash-based Message Authentication Code (HMAC) using the SHA1 hash function. |
ComputeSha256(String, Boolean)
Computes the SHA-256 hash of the given string using UTF8 byte encoding.
Declaration
public static byte[] ComputeSha256(string value, bool createHasher = false)
Parameters
| Type | Name | Description |
|---|---|---|
| String | value | The input string. |
| Boolean | createHasher | if set to |
Returns
| Type | Description |
|---|---|
| Byte[] | The computes a Hash-based Message Authentication Code (HMAC) by using the SHA256 hash function. |
ComputeSha512(String, Boolean)
Computes the SHA-512 hash of the given string using UTF8 byte encoding.
Declaration
public static byte[] ComputeSha512(string value, bool createHasher = false)
Parameters
| Type | Name | Description |
|---|---|---|
| String | value | The input string. |
| Boolean | createHasher | if set to |
Returns
| Type | Description |
|---|---|
| Byte[] | The computes a Hash-based Message Authentication Code (HMAC) using the SHA512 hash function. |