Class HashExtensions
Extension methods for computing hash values from bytes, strings, URIs, and streams.
public static class HashExtensions
- Inheritance
-
HashExtensions
- Inherited Members
Methods
ChangeFormat(HashString, HashFormat)
Converts a HashString to a different output format.
public static HashString ChangeFormat(this HashString hash, HashFormat format)
Parameters
hashHashStringformatHashFormat
Returns
FormatHash(Hash, HashFormat)
Formats a raw Hash into a HashString using the specified format.
public static HashString FormatHash(this Hash hash, HashFormat format)
Parameters
hashHashformatHashFormat
Returns
ToHash(byte[], HashFormat, HashType)
Computes a hash of the byte array and returns a formatted string representation.
public static HashString ToHash(this byte[] item, HashFormat format, HashType type = HashType.MD5)
Parameters
itembyte[]formatHashFormattypeHashType
Returns
ToHash(byte[], HashType)
Computes a hash of the specified byte array.
public static Hash ToHash(this byte[] item, HashType type = HashType.MD5)
Parameters
Returns
ToHash(string, HashFormat, HashType, Encoding)
Computes a hash of the string and returns a formatted string representation.
public static HashString ToHash(this string item, HashFormat format, HashType type = HashType.MD5, Encoding encoding = null)
Parameters
itemstringformatHashFormattypeHashTypeencodingEncoding
Returns
ToHash(string, HashType, Encoding)
Computes a hash of the specified string.
public static Hash ToHash(this string item, HashType type = HashType.MD5, Encoding encoding = null)
Parameters
itemstringThe string to hash.
typeHashTypeThe hash algorithm to use. Defaults to MD5.
encodingEncodingThe encoding to use. Defaults to UTF-8.
Returns
ToHash(Uri, HashFormat, HashType, Encoding)
Computes a hash of the URI and returns a formatted string representation.
public static HashString ToHash(this Uri item, HashFormat format, HashType type = HashType.MD5, Encoding encoding = null)
Parameters
itemUriformatHashFormattypeHashTypeencodingEncoding
Returns
ToHash(Uri, HashType, Encoding)
Computes a hash of the URI's absolute string representation.
public static Hash ToHash(this Uri item, HashType type = HashType.MD5, Encoding encoding = null)
Parameters
Returns
ToHashAndOutputAsync(Stream, Stream, HashFormat, HashType)
Asynchronously computes a hash while copying the stream, returning a formatted string.
public static Task<HashString> ToHashAndOutputAsync(this Stream input, Stream output, HashFormat format, HashType type = HashType.MD5)
Parameters
inputStreamoutputStreamformatHashFormattypeHashType
Returns
ToHashAndOutputAsync(Stream, Stream, HashType)
Asynchronously computes a hash while copying the stream content to an output stream.
public static Task<Hash> ToHashAndOutputAsync(this Stream input, Stream output, HashType type = HashType.MD5)
Parameters
Returns
ToHashAsync(Stream, HashFormat, HashType)
Asynchronously computes a hash from a stream and returns a formatted string representation.
public static Task<HashString> ToHashAsync(this Stream stream, HashFormat format, HashType type = HashType.MD5)
Parameters
streamStreamformatHashFormattypeHashType
Returns
ToHashAsync(Stream, HashType)
Asynchronously computes a hash from a stream.
public static Task<Hash> ToHashAsync(this Stream stream, HashType type = HashType.MD5)
Parameters
Returns
UnformatHash(HashString)
Converts a formatted HashString back to a raw Hash.
public static Hash UnformatHash(this HashString hash)
Parameters
hashHashString