using System.Security.Cryptography; using System.Text; namespace Project.Persistence; public static class ShaHash { public static string HashPassword(string password) { using (SHA256 sha256Hash = SHA256.Create()) { // convert string to byte array and hash byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(password)); // Byte-Array als Hex-String formatieren StringBuilder builder = new StringBuilder(); foreach (var b in bytes) { builder.Append(b.ToString("x2")); // x2 = hex format } return builder.ToString(); } } }