29 lines
701 B
C#
29 lines
701 B
C#
using System.Security.Cryptography;
|
|
using System.Text;
|
|
|
|
namespace LFlow.UserManagement.Util
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class PasswordHelper
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="password"></param>
|
|
/// <returns></returns>
|
|
public static string HashPassword(string password)
|
|
{
|
|
byte[] data = Encoding.Default.GetBytes(password);
|
|
byte[] hashData = MD5.HashData(data);
|
|
StringBuilder sb = new();
|
|
foreach (byte b in hashData)
|
|
{
|
|
sb.Append(b.ToString("x2"));
|
|
}
|
|
return sb.ToString();
|
|
}
|
|
}
|
|
}
|