refactor: move checking password
This commit is contained in:
@ -1,10 +1,11 @@
|
||||
using Konscious.Security.Cryptography;
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Mirea.Api.Security.Services;
|
||||
|
||||
public class PasswordHashService
|
||||
public partial class PasswordHashService
|
||||
{
|
||||
public int SaltSize { private get; init; }
|
||||
public int HashSize { private get; init; }
|
||||
@ -53,4 +54,15 @@ public class PasswordHashService
|
||||
|
||||
public bool VerifyPassword(string password, string saltBase64, string hashBase64) =>
|
||||
VerifyPassword(password, Convert.FromBase64String(saltBase64), Convert.FromBase64String(hashBase64));
|
||||
|
||||
public static bool HasPasswordInPolicySecurity(string password) =>
|
||||
password.Length >= 8 &&
|
||||
PasswordExistSpecialSymbol().IsMatch(password) &&
|
||||
PasswordExistUpperLetter().IsMatch(password);
|
||||
|
||||
[GeneratedRegex("[A-Z]+")]
|
||||
private static partial Regex PasswordExistUpperLetter();
|
||||
|
||||
[GeneratedRegex("[!@#$%^&*]+")]
|
||||
private static partial Regex PasswordExistSpecialSymbol();
|
||||
}
|
Reference in New Issue
Block a user