85 lines
3.0 KiB
C#
85 lines
3.0 KiB
C#
namespace System.Security.Cryptography
|
|
{
|
|
/// <summary>
|
|
/// Provides extension methods for the <see cref="CryptographyHelper"/> class.
|
|
/// </summary>
|
|
public static class CryptographyHelperExtensions
|
|
{
|
|
#region Hashing
|
|
|
|
#region MD5
|
|
|
|
/// <summary>
|
|
/// Computes a hash value from a string using the MD5 algorithm.
|
|
/// </summary>
|
|
/// <param name="str">The string to hash, using UTF-8 encoding.</param>
|
|
/// <returns>The MD5 hash value, in hexadecimal notation.</returns>
|
|
public static string Md5(this string str) => CryptographyHelper.Md5(str);
|
|
|
|
/// <summary>
|
|
/// Computes a hash from a byte array value using the MD5 algorithm.
|
|
/// </summary>
|
|
/// <param name="bytes">The byte array.</param>
|
|
/// <returns>The MD5 hash value, in hexadecimal notation.</returns>
|
|
public static string Md5(this byte[] bytes) => CryptographyHelper.Md5(bytes);
|
|
|
|
#endregion MD5
|
|
|
|
#region SHA-1
|
|
|
|
/// <summary>
|
|
/// Computes a hash value from a string using the SHA-1 algorithm.
|
|
/// </summary>
|
|
/// <param name="str">The string to hash, using UTF-8 encoding.</param>
|
|
/// <returns>The SHA-1 hash value, in hexadecimal notation.</returns>
|
|
public static string Sha1(this string str) => CryptographyHelper.Sha1(str);
|
|
|
|
/// <summary>
|
|
/// Computes a hash from a byte array value using the SHA-1 algorithm.
|
|
/// </summary>
|
|
/// <param name="bytes">The byte array.</param>
|
|
/// <returns>The SHA-1 hash value, in hexadecimal notation.</returns>
|
|
public static string Sha1(this byte[] bytes) => CryptographyHelper.Sha1(bytes);
|
|
|
|
#endregion SHA-1
|
|
|
|
#region SHA-256
|
|
|
|
/// <summary>
|
|
/// Computes a hash value from a string using the SHA-256 algorithm.
|
|
/// </summary>
|
|
/// <param name="str">The string to hash, using UTF-8 encoding.</param>
|
|
/// <returns>The SHA-256 hash value, in hexadecimal notation.</returns>
|
|
public static string Sha256(this string str) => CryptographyHelper.Sha256(str);
|
|
|
|
/// <summary>
|
|
/// Computes a hash from a byte array value using the SHA-256 algorithm.
|
|
/// </summary>
|
|
/// <param name="bytes">The byte array.</param>
|
|
/// <returns>The SHA-256 hash value, in hexadecimal notation.</returns>
|
|
public static string Sha256(this byte[] bytes) => CryptographyHelper.Sha256(bytes);
|
|
|
|
#endregion SHA-256
|
|
|
|
#region SHA-512
|
|
|
|
/// <summary>
|
|
/// Computes a hash value from a string using the SHA-512 algorithm.
|
|
/// </summary>
|
|
/// <param name="str">The string to hash, using UTF-8 encoding.</param>
|
|
/// <returns>The SHA-512 hash value, in hexadecimal notation.</returns>
|
|
public static string Sha512(this string str) => CryptographyHelper.Sha512(str);
|
|
|
|
/// <summary>
|
|
/// Computes a hash from a byte array value using the SHA-512 algorithm.
|
|
/// </summary>
|
|
/// <param name="bytes">The byte array.</param>
|
|
/// <returns>The SHA-512 hash value, in hexadecimal notation.</returns>
|
|
public static string Sha512(this byte[] bytes) => CryptographyHelper.Sha512(bytes);
|
|
|
|
#endregion SHA-512
|
|
|
|
#endregion Hashing
|
|
}
|
|
}
|