public static byte[] DecryptAes(byte[] Input, byte[] Key, byte[] IV = null)
{
if (IV == null) IV = new byte[16];
Logger.Notice("DecryptAes({0}, {1}, {2})", Input.Length, Key.Length, IV.Length);
using (var AES = Aes.Create())
{
AES.Padding = PaddingMode.Zeros;
var Decryptor = AES.CreateDecryptor(Key, IV);
int DataSize = Input.Length;
if ((DataSize % 16) != 0)
{
var Input2 = new byte[MathUtils.NextAligned(Input.Length, 16)];
Array.Copy(Input, Input2, Input.Length);
Input = Input2;
}
return new CryptoStream(new MemoryStream(Input), Decryptor, CryptoStreamMode.Read).ReadBytes(DataSize);
}
}