From cc2be73bb00ebfbe6f8a4d2205aea434c219d90c Mon Sep 17 00:00:00 2001 From: jvyden Date: Tue, 23 Nov 2021 18:29:07 -0500 Subject: [PATCH] Make HashHelper.Sha256Hash lowercase by default, fix ResetPasswordCommand --- ProjectLighthouse/CommandLine/ResetPasswordCommand.cs | 2 ++ ProjectLighthouse/Helpers/HashHelper.cs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ProjectLighthouse/CommandLine/ResetPasswordCommand.cs b/ProjectLighthouse/CommandLine/ResetPasswordCommand.cs index be2e5dd5..bfbb46c0 100644 --- a/ProjectLighthouse/CommandLine/ResetPasswordCommand.cs +++ b/ProjectLighthouse/CommandLine/ResetPasswordCommand.cs @@ -39,6 +39,8 @@ namespace LBPUnion.ProjectLighthouse.CommandLine user.Password = HashHelper.BCryptHash(password); + await this.database.SaveChangesAsync(); + Console.WriteLine($"The password for user {user.Username} (id: {user.UserId}) has been reset."); } } diff --git a/ProjectLighthouse/Helpers/HashHelper.cs b/ProjectLighthouse/Helpers/HashHelper.cs index 838a22a4..88012439 100644 --- a/ProjectLighthouse/Helpers/HashHelper.cs +++ b/ProjectLighthouse/Helpers/HashHelper.cs @@ -67,7 +67,7 @@ namespace LBPUnion.ProjectLighthouse.Helpers public static string Sha256Hash(string str) => Sha256Hash(Encoding.UTF8.GetBytes(str)); - public static string Sha256Hash(byte[] bytes) => BitConverter.ToString(sha256.ComputeHash(bytes)).Replace("-", ""); + public static string Sha256Hash(byte[] bytes) => BitConverter.ToString(sha256.ComputeHash(bytes)).Replace("-", "").ToLower(); public static string Sha1Hash(string str) => Sha1Hash(Encoding.UTF8.GetBytes(str));