ЛР 2: PostgreSQL, сессии, Redis и исследование

This commit is contained in:
Никита
2026-10-06 13:34:34 +03:00
parent 65003b6119
commit 6a8908ab99
111 changed files with 6686 additions and 38 deletions
@@ -0,0 +1,28 @@
using System.Security.Cryptography;
using System.Text;
using Isopoh.Cryptography.Argon2;
namespace Messenger.Api.Services;
public sealed class PasswordService
{
public string Hash(string password)
{
var salt = RandomNumberGenerator.GetBytes(16);
var config = new Argon2Config
{
Type = Argon2Type.HybridAddressing,
Version = Argon2Version.Nineteen,
TimeCost = 3,
MemoryCost = 32768,
Lanes = 1,
Threads = 1,
Password = Encoding.UTF8.GetBytes(password),
Salt = salt,
HashLength = 32
};
return Argon2.Hash(config);
}
public bool Verify(string hash, string password) => Argon2.Verify(hash, password);
}