using System.IO;
namespace System.Security.Cryptography
{
partial class Hashs
{
static SHA1 CreateSHA1()
{
try
{
return SHA1.Create();
}
catch
{
return new SHA1CryptoServiceProvider();
}
}
partial class String
{
partial class Lengths
{
public const int SHA1 = 40;
}
///
/// 计算SHA1值
///
///
///
///
public static string SHA1(string text, bool isLower = def_hash_str_is_lower) => ComputeHashString(text, CreateSHA1(), isLower);
///
/// 计算SHA1值
///
///
///
///
public static string SHA1(byte[] buffer, bool isLower = def_hash_str_is_lower) => ComputeHashString(buffer, CreateSHA1(), isLower);
///
/// 计算SHA1值
///
///
///
///
public static string SHA1(Stream inputStream, bool isLower = def_hash_str_is_lower) => ComputeHashString(inputStream, CreateSHA1(), isLower);
}
partial class ByteArray
{
///
/// 计算SHA1值
///
///
///
public static byte[] SHA1(byte[] buffer) => ComputeHash(buffer, CreateSHA1());
///
/// 计算SHA1值
///
///
///
public static byte[] SHA1(Stream inputStream) => ComputeHash(inputStream, CreateSHA1());
}
}
}