| 123456789101112131415161718192021222324 |
- using System.Security.Cryptography;
- using System.Text;
- namespace ComputerShopWpf.Services
- {
- public static class PasswordHasher
- {
- public static string ComputeSha256Hash(string rawData)
- {
- using (SHA256 sha256Hash = SHA256.Create())
- {
- byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(rawData ?? string.Empty));
- StringBuilder builder = new StringBuilder();
- for (int i = 0; i < bytes.Length; i++)
- {
- builder.Append(bytes[i].ToString("x2"));
- }
- return builder.ToString();
- }
- }
- }
- }
|