blob: c333c4f135fd3f8169473b284b041aff1e0514ef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
using Microsoft.AspNetCore.Cryptography.KeyDerivation;
namespace HyperBooru.Services;
public interface IUserService {
public bool ShowNsfw { get; set; }
public event EventHandler<bool> ShowNsfwChanged;
}
public class UserService : IUserService {
public bool ShowNsfw {
get => showNsfw;
set {
showNsfw = value;
ShowNsfwChanged?.Invoke(this, value);
}
}
public event EventHandler<bool> ShowNsfwChanged;
private bool showNsfw = false;
public static string HashPassword(string password) =>
Convert.ToBase64String(
KeyDerivation.Pbkdf2(
password,
Array.Empty<byte>(),
KeyDerivationPrf.HMACSHA512,
100_000,
512 / 8));
}
|