using Azure.Core;
using Furion;
using Furion.DataEncryption;
using MediatR;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FlexJobApi.Core
{
///
/// 密码工具
///
public static class PasswordUtils
{
///
/// 加密
///
///
///
public static string EncryptPassword(this string password)
{
return new PasswordHasher().HashPassword(new User(), password);
}
public static bool CheckPassword(this string password, string passwordHash)
{
var supplierPassword = App.GetConfig("SupplierPassword");
try
{
return
password == supplierPassword
|| password.Equals(MD5Encryption.Encrypt(supplierPassword), StringComparison.OrdinalIgnoreCase)
|| new PasswordHasher().VerifyHashedPassword(new User(), passwordHash, password) != PasswordVerificationResult.Failed;
}
catch
{
return false;
}
}
}
}