本文整理汇总了C#中System.Security.Cryptography.SHA384Managed.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# SHA384Managed.Clear方法的具体用法?C# SHA384Managed.Clear怎么用?C# SHA384Managed.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Cryptography.SHA384Managed
的用法示例。
在下文中一共展示了SHA384Managed.Clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SHA384Encrypt
/// <summary>
/// SHA384加密,不可逆转
/// </summary>
/// <param name="str">string str:被加密的字符串</param>
/// <returns>返回加密后的字符串</returns>
public string SHA384Encrypt(string str)
{
System.Security.Cryptography.SHA384 s384 = new System.Security.Cryptography.SHA384Managed();
byte[] byte1;
byte1 = s384.ComputeHash(Encoding.UTF8.GetBytes(str));
s384.Clear();
return Convert.ToBase64String(byte1);
}
示例2: SHA384Compute
public static byte[] SHA384Compute(byte[] data)
{
if (data == null)
throw new ArgumentNullException("data");
SHA384Managed SHA384 = new SHA384Managed();
byte[] hash = SHA384.ComputeHash(data);
SHA384.Clear();
return hash;
}
示例3: FromString
public static string FromString(string input, HashType hashtype)
{
Byte[] clearBytes;
Byte[] hashedBytes;
string output = String.Empty;
switch (hashtype)
{
case HashType.RIPEMD160:
clearBytes = new UTF8Encoding().GetBytes(input);
RIPEMD160 myRIPEMD160 = RIPEMD160Managed.Create();
hashedBytes = myRIPEMD160.ComputeHash(clearBytes);
output = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();
break;
case HashType.MD5:
clearBytes = new UTF8Encoding().GetBytes(input);
hashedBytes = ((HashAlgorithm)CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes);
output = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();
break;
case HashType.SHA1:
clearBytes = Encoding.UTF8.GetBytes(input);
SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider();
sha1.ComputeHash(clearBytes);
hashedBytes = sha1.Hash;
sha1.Clear();
output = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();
break;
case HashType.SHA256:
clearBytes = Encoding.UTF8.GetBytes(input);
SHA256 sha256 = new SHA256Managed();
sha256.ComputeHash(clearBytes);
hashedBytes = sha256.Hash;
sha256.Clear();
output = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();
break;
case HashType.SHA384:
clearBytes = Encoding.UTF8.GetBytes(input);
SHA384 sha384 = new SHA384Managed();
sha384.ComputeHash(clearBytes);
hashedBytes = sha384.Hash;
sha384.Clear();
output = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();
break;
case HashType.SHA512:
clearBytes = Encoding.UTF8.GetBytes(input);
SHA512 sha512 = new SHA512Managed();
sha512.ComputeHash(clearBytes);
hashedBytes = sha512.Hash;
sha512.Clear();
output = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();
break;
}
return output;
}