Authenticate is jó a passwordhas-sel
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlTypes;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -10,14 +12,12 @@ namespace WorkFlowCheck.Common.Security
|
||||
public static class PasswordHasher
|
||||
{
|
||||
// Jelszó hashelése
|
||||
private const string _saltstring = "xc45DDfrt!!ED210:";
|
||||
public static string HashPassword(string password)
|
||||
{
|
||||
// Generate a random salt
|
||||
byte[] salt = new byte[16];
|
||||
using (var rng = RandomNumberGenerator.Create())
|
||||
{
|
||||
rng.GetBytes(salt);
|
||||
}
|
||||
byte[] salt = Encoding.UTF8.GetBytes(_saltstring);
|
||||
|
||||
|
||||
// Hash the password with the salt
|
||||
using (var rfc2898 = new Rfc2898DeriveBytes(password, salt, 10000, HashAlgorithmName.SHA256))
|
||||
@@ -37,7 +37,7 @@ namespace WorkFlowCheck.Common.Security
|
||||
byte[] hashBytes = Convert.FromBase64String(storedPasswordHash);
|
||||
|
||||
// Extract salt (first 16 bytes) and stored hash (next 32 bytes)
|
||||
byte[] salt = new byte[16];
|
||||
byte[] salt = Encoding.UTF8.GetBytes(_saltstring);
|
||||
byte[] storedHash = new byte[32];
|
||||
Array.Copy(hashBytes, 0, salt, 0, 16);
|
||||
Array.Copy(hashBytes, 16, storedHash, 0, 32);
|
||||
|
||||
Reference in New Issue
Block a user