标签:
SHA1和MD5加密均为不可逆加密。代码如下:
using System.Security.Cryptography; //添加Using static void Main(string[] args) { string password = "0123456789"; //SHA1加密方法 var sha1 = new SHA1CryptoServiceProvider(); byte[] str01 = Encoding.Default.GetBytes(password); byte[] str02 = sha1.ComputeHash(str01); var result = BitConverter.ToString(str02).Replace("-", ""); //MD5加密方法 var md5 = new MD5CryptoServiceProvider(); byte[] str1 = Encoding.Default.GetBytes(password); byte[] str2 = md5.ComputeHash(str1); var rethash = BitConverter.ToString(str2).Replace("-", ""); Console.WriteLine(rethash); Console.WriteLine(result); Console.Read(); }
标签:
原文地址:http://www.cnblogs.com/BHfeimao/p/5262640.html