22 lines
642 B
C#
22 lines
642 B
C#
using System.Security.Cryptography;
|
|
|
|
namespace InnovEnergy.App.Backend.Utils;
|
|
|
|
public static class Crypto
|
|
{
|
|
public static String ComputeHash(Byte[] bytesToHash, Byte[] salt)
|
|
{
|
|
using var mySHA256 = SHA256.Create();
|
|
var hashValue = mySHA256.ComputeHash(bytesToHash);
|
|
// var hashValue = new Rfc2898DeriveBytes(hashValue, salt, 10000);
|
|
return Convert.ToBase64String(hashValue);
|
|
}
|
|
|
|
public static String GenerateSalt()
|
|
{
|
|
var bytes = new Byte[128 / 8];
|
|
var rng = RandomNumberGenerator.Create();
|
|
rng.GetBytes(bytes);
|
|
return Convert.ToBase64String(bytes);
|
|
}
|
|
} |