Skip to content

Commit

Permalink
Don't reuse instances of SHA256 when hashing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Slendy committed Jun 25, 2024
1 parent 573e7c4 commit 541172b
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions ProjectLighthouse/Helpers/CryptoHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ namespace LBPUnion.ProjectLighthouse.Helpers;

public static class CryptoHelper
{

private static readonly SHA256 sha256 = SHA256.Create();

/// <summary>
/// Generates a random SHA256 and BCrypted token
/// </summary>
Expand Down Expand Up @@ -156,7 +153,7 @@ private static bool ValuesEqual(string a, string b)

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("-", "");

Expand Down

0 comments on commit 541172b

Please sign in to comment.