summaryrefslogtreecommitdiffstats
path: root/src/Utilities/PasswordHasher.cs
diff options
context:
space:
mode:
authorivar <i@oiee.no>2025-10-19 23:41:23 +0200
committerivar <i@oiee.no>2025-10-19 23:41:23 +0200
commit3f4c0720e1e3421431e7baa20882a4a4512a7fab (patch)
tree734ca81d7d0841d8863e3f523ebba14c282dc681 /src/Utilities/PasswordHasher.cs
downloadfagprove-3f4c0720e1e3421431e7baa20882a4a4512a7fab.tar.xz
fagprove-3f4c0720e1e3421431e7baa20882a4a4512a7fab.zip
InitialHEADmaster
Diffstat (limited to 'src/Utilities/PasswordHasher.cs')
-rw-r--r--src/Utilities/PasswordHasher.cs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Utilities/PasswordHasher.cs b/src/Utilities/PasswordHasher.cs
new file mode 100644
index 0000000..213e03d
--- /dev/null
+++ b/src/Utilities/PasswordHasher.cs
@@ -0,0 +1,18 @@
+using IOL.Fagprove.Data.Models;
+using Microsoft.AspNetCore.Identity;
+
+namespace IOL.Fagprove.Utilities
+{
+ public static class PasswordHasher
+ {
+ public static string HashPassword(string password) {
+ var hasher = new PasswordHasher<User>();
+ return hasher.HashPassword(null, password);
+ }
+
+ public static bool PasswordMatches(string hash, string password) {
+ var hasher = new PasswordHasher<User>();
+ return hasher.VerifyHashedPassword(null, hash, password) == PasswordVerificationResult.Success;
+ }
+ }
+} \ No newline at end of file