32 lines
No EOL
700 B
C#
32 lines
No EOL
700 B
C#
using System.Security.Cryptography;
|
|
using System.Text;
|
|
using Website.Data.States;
|
|
|
|
namespace Website.Models {
|
|
public class User {
|
|
public User() {
|
|
}
|
|
|
|
public User(UserState state) {
|
|
Username = state.User_Email;
|
|
Password = state.User_Password;
|
|
}
|
|
|
|
public bool ValidatePassword(string password) {
|
|
using (var sha256 = SHA256.Create()) {
|
|
var hash = sha256.ComputeHash(Encoding.UTF8.GetBytes(password));
|
|
|
|
var builder = new StringBuilder();
|
|
foreach (var b in hash)
|
|
builder.Append(b.ToString("x2"));
|
|
var hashString = builder.ToString();
|
|
|
|
return hashString == Password;
|
|
}
|
|
}
|
|
|
|
|
|
public string Username { get; set; }
|
|
public string Password { get; set; }
|
|
}
|
|
} |