fix(core): Streamlines text encoding (#407)

- [X] Streamlines text encoding
This commit is contained in:
Kamron Batman 2021-01-13 18:56:32 -08:00 • committed by GitHub
parent 5631c1da6d
commit 211c2ba8ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 274 additions and 137 deletions

View file

@ -16,6 +16,7 @@
using System;
using System.Security.Cryptography;
using System.Text;
using Server.Text;
namespace Server.Accounting.Security
{
@ -26,10 +27,7 @@ namespace Server.Accounting.Security
public string EncryptPassword(string plainPassword)
{
var password = plainPassword.AsSpan(0, Math.Min(256, plainPassword.Length));
var bytes = GC.AllocateUninitializedArray<byte>(Encoding.ASCII.GetByteCount(password));
Encoding.ASCII.GetBytes(password, bytes);
byte[] bytes = plainPassword.AsSpan(0, Math.Min(256, plainPassword.Length)).GetBytesAscii();
return m_SHA2HashProvider.ComputeHash(bytes).ToHexString();
}