Testing more garbage encryption

This commit is contained in:
gamer147
2024-09-07 22:14:24 -04:00
parent f7657c2ec4
commit 7e4bce9ac5
32 changed files with 783 additions and 51 deletions

View File

@@ -58,27 +58,29 @@ public static class Encryption
/// <returns>the decrypted bytes</returns>
public static byte[] Decrypt(byte[] encryptedData, string udId)
{
using (var rj = Aes.Create())
using (var rj = new RijndaelManaged())
{
rj.KeySize = EncryptionKeySize;
rj.Mode = EncryptionMode;
rj.BlockSize = EncryptionBlockSize;
//rj.Padding = PaddingMode.None;
byte[] rgbIv = Encoding.UTF8.GetBytes(udId.Replace("-", string.Empty).Substring(0, UdIdKeySize));
byte[] keyBytes = new byte[KeyStringSize];
byte[] encryptedValueBytes = new byte[encryptedData.Length - KeyStringSize];
Array.Copy(encryptedData, encryptedData.Length - keyBytes.Length, keyBytes, 0, keyBytes.Length);
Array.Copy(encryptedData, 0, encryptedValueBytes, 0, encryptedValueBytes.Length);
ICryptoTransform transform = rj.CreateDecryptor(keyBytes, rgbIv);
byte[] decryptedValueBytes = new byte[encryptedValueBytes.Length];
using (MemoryStream ms = new MemoryStream(encryptedValueBytes))
{
using (CryptoStream cs = new CryptoStream(ms, transform, CryptoStreamMode.Read))
{
byte[] decryptedValueBytes = new byte[encryptedValueBytes.Length];
cs.Read(decryptedValueBytes, 0, encryptedValueBytes.Length);
cs.FlushFinalBlock();
return decryptedValueBytes;
cs.CopyTo(decryptedValueBytes);
cs.Flush();
ms.Flush();
}
}
return decryptedValueBytes;
}
}