using System.Security.Cryptography;
string password = "HelloWord1234";
//SHA1 hash
SHA1 sha1 = new SHA1CryptoServiceProvider();
byte[] hexsha1= sha1.ComputeHash(Encoding.UTF8.GetBytes(cTmpStr));
//『Result』
string resultSha1 = ToHexString(hexsha1); // Call for ToHexString Method
/**
* HexString Method
* return: string
**/
private static string ToHexString(byte[] bytes)
{
string hexString = string.Empty;
if (bytes != null)
{
StringBuilder strB = new StringBuilder();
for (int i = 0; i < bytes.Length; i++)
{
strB.Append(bytes[i].ToString("X2"));
}
hexString = strB.ToString();
}
return hexString;
}
SHA-1 hash ( Hexstring )
This sample was used to hash password or secret message.
This sample was used to hash password or secret message.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.