Exemplo n.º 1
0
 public byte[] Decrypt(byte[] data)
 {
     using (var sIn = new MemoryStream())
     {
         using (var provider = SymmetricAlgorithm.Create(ProviderName))
         {
             using (var dec = new CryptoStream(sIn, provider.CreateDecryptor(ToArray(Key), ToArray(IV)), CryptoStreamMode.Read))
             {
                 return dec.ReadToEnd();
             }
         }
     }
 }
Exemplo n.º 2
0
 public byte[] Encrypt(byte[] data)
 {
     using (var sOut = new MemoryStream())
     {
         using (var provider = SymmetricAlgorithm.Create(ProviderName))
         {
             using (var enc = new CryptoStream(sOut, provider.CreateEncryptor(ToArray(Key), ToArray(IV)), CryptoStreamMode.Write))
             {
                 enc.Write(data, 0, data.Length);
                 return enc.ReadToEnd();
             }
         }
     }
 }