From 541172b001802e01573fe3b6e1fdfe30cfea968f Mon Sep 17 00:00:00 2001 From: Slendy Date: Tue, 25 Jun 2024 04:38:21 -0500 Subject: [PATCH] Don't reuse instances of SHA256 when hashing. --- ProjectLighthouse/Helpers/CryptoHelper.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ProjectLighthouse/Helpers/CryptoHelper.cs b/ProjectLighthouse/Helpers/CryptoHelper.cs index cfa896a2..58a5282c 100644 --- a/ProjectLighthouse/Helpers/CryptoHelper.cs +++ b/ProjectLighthouse/Helpers/CryptoHelper.cs @@ -9,9 +9,6 @@ namespace LBPUnion.ProjectLighthouse.Helpers; public static class CryptoHelper { - - private static readonly SHA256 sha256 = SHA256.Create(); - /// /// Generates a random SHA256 and BCrypted token /// @@ -156,7 +153,7 @@ public static class CryptoHelper public static string Sha256Hash(string str) => Sha256Hash(Encoding.UTF8.GetBytes(str)); - public static string Sha256Hash(byte[] bytes) => BitConverter.ToString(sha256.ComputeHash(bytes)).Replace("-", "").ToLower(); + public static string Sha256Hash(byte[] bytes) => BitConverter.ToString(SHA256.HashData(bytes)).Replace("-", "").ToLower(); public static string Sha1Hash(byte[] bytes) => BitConverter.ToString(SHA1.HashData(bytes)).Replace("-", "");