1
0

Refactoring

This commit is contained in:
2021-10-22 21:05:37 +02:00
commit ca9de13c9e
43 changed files with 5145 additions and 0 deletions

View File

@@ -0,0 +1,84 @@
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(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(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
}
}