added salt to password, it's edible now
This commit is contained in:
parent
d3be39d265
commit
9d19c0fca9
|
@ -0,0 +1,20 @@
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
|
namespace Backend.Utils;
|
||||||
|
|
||||||
|
public class Crypto
|
||||||
|
{
|
||||||
|
public String ComputeHash(Byte[] bytesToHash, Byte[] salt)
|
||||||
|
{
|
||||||
|
var byteResult = new Rfc2898DeriveBytes(bytesToHash, salt, 10000);
|
||||||
|
return Convert.ToBase64String(byteResult.GetBytes(24));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GenerateSalt()
|
||||||
|
{
|
||||||
|
var bytes = new byte[128 / 8];
|
||||||
|
var rng = new RNGCryptoServiceProvider();
|
||||||
|
rng.GetBytes(bytes);
|
||||||
|
return Convert.ToBase64String(bytes);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue