From 12bbbffbe9c6fe764cc9161e40419e0a7902fa05 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 2 Jan 2023 13:55:02 -0600 Subject: add SHA256 hash function --- src/slskd/Common/Compute.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/slskd/Common/Compute.cs b/src/slskd/Common/Compute.cs index b9dc882a..befceb88 100644 --- a/src/slskd/Common/Compute.cs +++ b/src/slskd/Common/Compute.cs @@ -20,7 +20,6 @@ namespace slskd using System; using System.Security.Cryptography; using System.Text; - using System.Text.RegularExpressions; /// /// Computational functions. @@ -44,5 +43,11 @@ namespace slskd using var sha1 = SHA1.Create(); return BitConverter.ToString(sha1.ComputeHash(Encoding.UTF8.GetBytes(str))).Replace("-", string.Empty); } + + public static string Sha256Hash(string str) + { + using var sha256 = SHA256.Create(); + return BitConverter.ToString(sha256.ComputeHash(Encoding.UTF8.GetBytes(str))).Replace("-", string.Empty); + } } } \ No newline at end of file -- cgit v1.2.3