nove verzije
This commit is contained in:
@@ -102,5 +102,32 @@ namespace ResevalnaScanner.Classes
|
||||
|
||||
return Encoding.UTF8.GetString(plainTextBytes, 0, byteCount).Trim();
|
||||
}
|
||||
|
||||
public const int SALT_SIZE = 24; // size in bytes
|
||||
public const int HASH_SIZE = 256; // size in bytes
|
||||
public const int ITERATIONS = 20000; // number of pbkdf2 iterations
|
||||
|
||||
public static (byte[] Hash, byte[] Salt) CreatePasswordHash(string iText, byte[]? iSalt = null)
|
||||
{
|
||||
byte[] salt;
|
||||
if (iSalt == null)
|
||||
{
|
||||
salt = new byte[SALT_SIZE];
|
||||
using var rng = RandomNumberGenerator.Create();
|
||||
rng.GetBytes(salt);
|
||||
}
|
||||
else
|
||||
{
|
||||
salt = iSalt;
|
||||
}
|
||||
|
||||
var pbkdf2 = new Rfc2898DeriveBytes(iText, salt, ITERATIONS, HashAlgorithmName.SHA256);
|
||||
return (pbkdf2.GetBytes(HASH_SIZE), salt);
|
||||
}
|
||||
|
||||
public static bool CompareByteArrays(byte[] iArray, byte[] iArrayToCompare)
|
||||
{
|
||||
return iArray.Length == iArrayToCompare.Length && !iArray.Where((t, i) => t != iArrayToCompare[i]).ToList().Any();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
16
InfosysPublisher/Classes/User.cs
Normal file
16
InfosysPublisher/Classes/User.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace InfosysPublisher.Classes
|
||||
{
|
||||
internal class User
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Surname { get; set; }
|
||||
public string Username { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user