17 lines
417 B
C#
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));
|
|
}
|