EncodeAndHashString Method
EncodeAndHashString(String)
Helper function that takes a string and computes the SHA-256 hash of the UTF-8 encoding.
public static byte[] EncodeAndHashString(string data)
Parameters
Type | Name | Description |
---|---|---|
System.String | data | The string to encode. |
Returns
The SHA-256 hash of the string encoded as UTF-8.
Remarks
Use this helper function to simplify calling other U2F functions such as Register(ReadOnlyMemory<Byte>, ReadOnlyMemory<Byte>, TimeSpan) and
Authenticate. This function will take the provided string, encode it into a byte array using the UTF-8
encoding style, and then pass those bytes into a SHA256 hash function. This transformation can be used for
things like the applicationId
and the clientDataHash
.
This function uses the SHA256 cryptographic function. By default, this will rely on the implementation provided by the .NET base class library. If you wish to override this implementation with your own, you can do so by setting a SHA256 creator on the CryptographyProviders class. See the User's manual page on providing alternate cryptographic implementations for more information.