Class Hash
Represents a utility class for cryptographic hashing operations using SHA-1, SHA-256, or SHA-512. Provides methods to compute hashes for byte arrays with optional key-based hashing or iterative hashing for password-based systems.
public class Hash
- Inheritance
-
Hash
- Inherited Members
Methods
ComputeHash(byte[])
Computes the hash of the provided byte array using the configured hash algorithm.
public byte[] ComputeHash(byte[] value)
Parameters
valuebyte[]The byte array to compute the hash for.
Returns
- byte[]
A byte array representing the computed hash.
ComputeHash(byte[], byte[])
Computes the hash of the specified data using the given key.
public byte[] ComputeHash(byte[] value, byte[] key)
Parameters
Returns
- byte[]
A byte array containing the computed hash.
ComputeHash(byte[], IEnumerable<byte>, int)
Computes a cryptographic hash using the provided password, salt, and iterations.
public byte[] ComputeHash(byte[] password, IEnumerable<byte> salt, int iterations)
Parameters
passwordbyte[]The byte array representing the password to hash.
saltIEnumerable<byte>The byte array used as the salt for the hash.
iterationsintThe number of iterations to perform on the hash.
Returns
- byte[]
A byte array containing the computed hash value.
Exceptions
- ArgumentOutOfRangeException
Thrown when
iterationsis less than one.
Sha1()
Gets a new SHA1 hash.
public static Hash Sha1()
Returns
Sha256()
Gets a new SHA256 hash.
public static Hash Sha256()
Returns
Sha512()
Gets a new SHA512 hash.
public static Hash Sha512()