Add an IV for string encryption

This commit is contained in:
CasualPokePlayer 2024-11-08 12:09:19 -08:00
parent 4c3b59c39c
commit 411959e399
1 changed files with 4 additions and 2 deletions

View File

@ -53,8 +53,10 @@ namespace BizHawk.Common
static SecretStrings()
{
_aes = Aes.Create();
_aes.Key = SHA256Checksum.Compute(Encoding.UTF8.GetBytes($"{GetMachineGuid()}/{Environment.MachineName}"));
_aes.IV = new byte[_aes.BlockSize / 8];
var machineIdBytes = Encoding.UTF8.GetBytes($"{GetMachineGuid()}/{Environment.MachineName}");
var machineIdHash = SHA256Checksum.Compute(machineIdBytes);
_aes.Key = machineIdHash;
_aes.IV = SHA256Checksum.Compute([ ..machineIdHash, ..machineIdBytes ]).AsSpan(0, 16).ToArray();
_aes.Mode = CipherMode.CBC;
_aes.Padding = PaddingMode.PKCS7;
}