using System.Security.Cryptography; namespace Lobbies { internal class PasswordHash { const int keySize = 64; const int saltSize = 16; const int iterations = 350000; static HashAlgorithmName hashAlgorithm = HashAlgorithmName.SHA512; static internal (byte[] hash, byte[] salt) Hash(string text) { using (var pbkdf2 = new Rfc2898DeriveBytes( text, saltSize, iterations, hashAlgorithm)) { return (pbkdf2.GetBytes(keySize), pbkdf2.Salt); } } static internal byte[] Hash(string text, byte[] salt) { using (var pbkdf2 = new Rfc2898DeriveBytes( text, salt, iterations, hashAlgorithm)) { return pbkdf2.GetBytes(keySize); } } } }