Emberend/Helpers/PasswordHelper.cs
2026-01-20 19:05:17 +01:00

17 lines
417 B
C#

using System.Security.Cryptography;
using System.Text;
namespace Emberend.Helpers;
static class PasswordHasher
{
public static string Hash(string password, string salt)
{
var bytes = Encoding.UTF8.GetBytes(password + salt);
return Convert.ToHexString(SHA256.HashData(bytes));
}
public static string NewSalt() =>
Convert.ToHexString(RandomNumberGenerator.GetBytes(16));
}