From 604ef537e0fabfbcc3abf9d7473b22f08dc549a6 Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Thu, 14 Sep 2023 14:41:40 +1000 Subject: Finalised login functionality --- Services/UserService.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'Services') diff --git a/Services/UserService.cs b/Services/UserService.cs index d2abea3..c333c4f 100644 --- a/Services/UserService.cs +++ b/Services/UserService.cs @@ -1,4 +1,6 @@ -namespace HyperBooru.Services; +using Microsoft.AspNetCore.Cryptography.KeyDerivation; + +namespace HyperBooru.Services; public interface IUserService { public bool ShowNsfw { get; set; } @@ -18,4 +20,13 @@ public class UserService : IUserService { public event EventHandler ShowNsfwChanged; private bool showNsfw = false; + + public static string HashPassword(string password) => + Convert.ToBase64String( + KeyDerivation.Pbkdf2( + password, + Array.Empty(), + KeyDerivationPrf.HMACSHA512, + 100_000, + 512 / 8)); } -- cgit v1.3