SHA加密
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
namespace SHA加密练习1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("----------");
string sha = Console.ReadLine();
string sha_1= SHA_Encrypt(sha);
Console.WriteLine(sha_1);
Console.ReadKey();
}
public static string SHA_Encrypt(string sourceString)
{
byte[] StrRes = Encoding.UTF8.GetBytes(sourceString);
HashAlgorithm iSHA = new SHA1CryptoServiceProvider();
StrRes = iSHA.ComputeHash(StrRes);
StringBuilder EnText = new StringBuilder();
foreach (byte item in StrRes)
{
EnText.AppendFormat("{0:x2}", item);
}
return EnText.ToString();
}
}
}