Class HashService
- Namespace
- AetherUtils.Core.Security.Hashing
- Assembly
- AetherUtils.Core.dll
Provides a service for creating cryptographically strong hashes of strings and comparing plain-text
strings against them for equality.
This class hashes strings based on the provided HashOptions.
public sealed class HashService
- Inheritance
-
HashService
- Inherited Members
- Extension Methods
Constructors
HashService(HashOptions)
Create a new service with the specified HashOptions.
public HashService(HashOptions options)
Parameters
optionsHashOptions- The options that should be used for hashing.
Properties
HashedString
Get the hashed string for this HashService.
public string HashedString { get; }
Property Value
Methods
CompareHash(string)
Compare a non-hashed input string against the last hashed string for this HashService
.
public bool CompareHash(string input)
Parameters
inputstring
Returns
- bool
trueif the two strings are equivalent;falseotherwise.
Exceptions
- ArgumentException
- Thrown if
inputisnullor empty.
CompareHash(string, string)
public static bool CompareHash(string input, string hashString)
Parameters
Returns
- bool
trueif the two strings are equivalent;falseotherwise.
Exceptions
- ArgumentException
- Thrown if
inputorhashStringarenullor empty.
HashString(string)
Generate a hash string for the specified plain-text string according to this object's HashOptions.
public string HashString(string value)
Parameters
valuestring- The plain text string to hash.
Returns
- string
- A cryptographically strong hashed string.
Exceptions
- CryptographicException
- If HashAlgorithm is an unsupported hash algorithm. Supported algorithms are SHA1, SHA256, SHA384, and SHA512