using System.Security.Cryptography;
public static void Main(String[] args)
byte[] iv = { 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1, 7, 7, 7, 7 };
Teste(128 , 256 , new byte[1] , iv);
public static void Teste(int BLockSize , int keySize, byte[] key , byte[] iv){
RijndaelManaged aes = new RijndaelManaged();
aes.BlockSize = BLockSize;
string json = @"{ ""cod_contrato"" : ""10"", ""DataInicio"" : ""2018-08-28"", ""DataFinal"": ""2018-08-29"" }";
string chave = "078348529648661693abf264311a8e56";
aes.Mode = CipherMode.CBC;
aes.Padding = PaddingMode.PKCS7;
aes.Key = System.Text.Encoding.UTF8.GetBytes(chave);
ICryptoTransform encryptor = aes.CreateEncryptor(aes.Key , aes.IV);
byte[] encript = encryptor.TransformFinalBlock(ASCIIEncoding.ASCII.GetBytes(json),0,json.Length);
string str = Convert.ToBase64String(encript);
Console.WriteLine("Vetor inicial: {0}", iv);
Console.WriteLine("Encrypted (b64-encode): {0}", str);
RijndaelManaged aesd = new RijndaelManaged();
aesd.Mode = CipherMode.CBC;
aesd.Padding = PaddingMode.PKCS7;
aesd.Key = System.Text.Encoding.UTF8.GetBytes(chave);
ICryptoTransform decryptor = aesd.CreateDecryptor(aesd.Key , aesd.IV);
byte[] decript = Convert.FromBase64String("y6F0nbQcg3YrO+cMueWnMdTTOCVKYLEtmA7QZT4iNtqmOipRhBsQvcX3VO5sHIz7bK46dnFAvfPf6uAJRA54g0E12Etkf4zMYpW2IgFvyWr5DpZ81QSbI25KO+KgdFxJW1LBY2j8rooDqPxPASiDuQ==");
using (MemoryStream msDecrypt = new MemoryStream(decript))
using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
using (StreamReader srDecrypt = new StreamReader(csDecrypt))
plaintext = srDecrypt.ReadToEnd();
Console.WriteLine("Removendo cifragem (b64-encode): {0}", plaintext);