|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
using Microsoft.AspNetCore.Cryptography.KeyDerivation;
|
|
|
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
|
using BCrypt.Net;
|
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.Text;
|
|
|
|
@ -22,18 +23,24 @@ public class AdministratorModel
|
|
|
|
|
|
|
|
|
|
public void HashPassword(string password)
|
|
|
|
|
{
|
|
|
|
|
using (MD5 md5 = MD5.Create())
|
|
|
|
|
{
|
|
|
|
|
byte[] inputBytes = Encoding.UTF8.GetBytes(password);
|
|
|
|
|
byte[] hashBytes = md5.ComputeHash(inputBytes);
|
|
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
for (int i = 0; i < hashBytes.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
sb.Append(hashBytes[i].ToString("x2"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HashedPassword = sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
this.HashedPassword = BCrypt.Net.BCrypt.HashPassword(password, BCrypt.Net.BCrypt.GenerateSalt());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//public void HashPassword(string password)
|
|
|
|
|
//{
|
|
|
|
|
// using (MD5 md5 = MD5.Create())
|
|
|
|
|
// {
|
|
|
|
|
// byte[] inputBytes = Encoding.UTF8.GetBytes(password);
|
|
|
|
|
// byte[] hashBytes = md5.ComputeHash(inputBytes);
|
|
|
|
|
|
|
|
|
|
// StringBuilder sb = new StringBuilder();
|
|
|
|
|
// for (int i = 0; i < hashBytes.Length; i++)
|
|
|
|
|
// {
|
|
|
|
|
// sb.Append(hashBytes[i].ToString("x2"));
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// HashedPassword = sb.ToString();
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|