diff --git a/Projects/UOContent/Accounting/Security/PBKDF2PasswordProtection.cs b/Projects/UOContent/Accounting/Security/PBKDF2PasswordProtection.cs index 001361177..96706c030 100644 --- a/Projects/UOContent/Accounting/Security/PBKDF2PasswordProtection.cs +++ b/Projects/UOContent/Accounting/Security/PBKDF2PasswordProtection.cs @@ -22,24 +22,24 @@ namespace Server.Accounting.Security; public class PBKDF2PasswordProtection : IPasswordProtection { - private const ushort m_MinIterations = 1024; - private const ushort m_MaxIterations = 1536; - private const int m_SaltSize = 8; - private const int m_HashSize = 32; - private const int m_OutputSize = 2 + m_SaltSize + m_HashSize; + private const ushort MinIterations = 1024; + private const ushort MaxIterations = 1536; + private const int SaltSize = 8; + private const int HashSize = 32; + private const int OutputSize = 2 + SaltSize + HashSize; public static readonly IPasswordProtection Instance = new PBKDF2PasswordProtection(); public string EncryptPassword(string plainPassword) { - Span output = stackalloc byte[m_OutputSize]; + Span output = stackalloc byte[OutputSize]; - var iterations = RandomNumberGenerator.GetInt32(m_MinIterations, m_MaxIterations + 1); + var iterations = RandomNumberGenerator.GetInt32(MinIterations, MaxIterations + 1); BinaryPrimitives.WriteUInt16LittleEndian(output[..2], (ushort)iterations); - var salt = output.Slice(2, m_SaltSize); + var salt = output.Slice(2, SaltSize); RandomNumberGenerator.Fill(salt); - var hash = output.Slice(2 + m_SaltSize, m_HashSize); + var hash = output.Slice(2 + SaltSize, HashSize); Rfc2898DeriveBytes.Pbkdf2(plainPassword, salt, hash, iterations, HashAlgorithmName.SHA256); return output.ToHexString(); @@ -47,15 +47,15 @@ public class PBKDF2PasswordProtection : IPasswordProtection public bool ValidatePassword(string encryptedPassword, string plainPassword) { - Span encryptedBytes = stackalloc byte[m_OutputSize]; + Span encryptedBytes = stackalloc byte[OutputSize]; encryptedPassword.GetBytes(encryptedBytes); var iterations = BinaryPrimitives.ReadUInt16LittleEndian(encryptedBytes[..2]); - var salt = encryptedBytes.Slice(2, m_SaltSize); + var salt = encryptedBytes.Slice(2, SaltSize); - Span hash = stackalloc byte[m_HashSize]; + Span hash = stackalloc byte[HashSize]; Rfc2898DeriveBytes.Pbkdf2(plainPassword, salt, hash, iterations, HashAlgorithmName.SHA256); - return hash.SequenceEqual(encryptedBytes[(m_SaltSize + 2)..]); + return hash.SequenceEqual(encryptedBytes[(SaltSize + 2)..]); } } diff --git a/Projects/UOContent/Accounting/Security/PasswordWorker.cs b/Projects/UOContent/Accounting/Security/PasswordWorker.cs index 98e72b833..83e9207f1 100644 --- a/Projects/UOContent/Accounting/Security/PasswordWorker.cs +++ b/Projects/UOContent/Accounting/Security/PasswordWorker.cs @@ -2,7 +2,7 @@ * ModernUO * * Copyright 2019-2026 - ModernUO Development Team * * Email: hi@modernuo.com * - * File: PasswordWorker.cs * + * File: PasswordWorker.cs * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by *