add profile edition route and a keep alive route
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
7714126252
commit
aab1eb74a2
@ -0,0 +1,35 @@
|
||||
using System.Security.Cryptography;
|
||||
using Microsoft.AspNetCore.Cryptography.KeyDerivation;
|
||||
|
||||
namespace DbServices;
|
||||
|
||||
public class Hashing
|
||||
{
|
||||
public static (string, byte[]) HashString(string str)
|
||||
{
|
||||
byte[] salt = RandomNumberGenerator.GetBytes(128 / 8);
|
||||
string hashed = Convert.ToBase64String(KeyDerivation.Pbkdf2(
|
||||
password: str,
|
||||
salt,
|
||||
prf: KeyDerivationPrf.HMACSHA256,
|
||||
iterationCount: 50000,
|
||||
numBytesRequested: 256 / 8
|
||||
));
|
||||
|
||||
return (hashed, salt);
|
||||
}
|
||||
|
||||
public static bool PasswordsMatches(string password, string str, byte[] salt)
|
||||
{
|
||||
string hashed = Convert.ToBase64String(KeyDerivation.Pbkdf2(
|
||||
password: str,
|
||||
salt,
|
||||
prf: KeyDerivationPrf.HMACSHA256,
|
||||
iterationCount: 50000,
|
||||
numBytesRequested: 256 / 8
|
||||
));
|
||||
|
||||
return hashed == password;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue