Method ComputeHash
ComputeHash(string, ReadOnlySpan<byte>)
Computes the keyed hash (HMAC-SHA256) of a code, as 43 base64url characters. The code is normalized first, so typed input gives the same hash as the generated code.
Declaration
public static string ComputeHash(string code, ReadOnlySpan<byte> key)
Parameters
| Type | Name | Description |
|---|---|---|
| string | code | The code. |
| ReadOnlySpan<byte> | key | The secret key of the hash, at least MinHashKeyLength bytes long. Only someone who has the key can tell which code a hash belongs to. |
Returns
| Type | Description |
|---|---|
| string |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | The value is not a valid code, or the key is shorter than MinHashKeyLength bytes. |