using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace hashTest1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(HashPassword("123"));
Console.Read();
}//end main
static string HashPassword(string password)
{
string hashCode = "";
System.Security.Cryptography.SHA1 hash = System.Security.Cryptography.SHA1.Create();
ASCIIEncoding encoder = new ASCIIEncoding();
byte[] combined = encoder.GetBytes(password);
hash.ComputeHash(combined);
hashCode = Convert.ToBase64String(hash.Hash);
return hashCode;
}
}//end class
}
将密码变成哈希值
最新推荐文章于 2025-04-01 18:00:00 发布