예제 #1
0
 public static byte[] EncryptData(CryptoKey cryptoKey, CryptoIV cryptoIV, byte[] data)
 {
     // Advanced Encryption Standard
     ICryptoTransform encryptor = new RijndaelManaged().CreateEncryptor(cryptoKey, cryptoIV);
     using (MemoryStream stream = new MemoryStream())
     {
         using (CryptoStream cryptoStream = new CryptoStream(stream, encryptor, CryptoStreamMode.Write))
         {
             cryptoStream.Write(data, 0, data.Length);
             cryptoStream.FlushFinalBlock();
             return stream.ToArray();
         }
     }
 }
예제 #2
0
 public static byte[] EncryptData(byte[] data, out CryptoKey cryptoKey, out CryptoIV cryptoIV)
 {
     cryptoKey = new CryptoKey();
     cryptoIV = new CryptoIV();
     return EncryptData(cryptoKey, cryptoIV, data);
 }
예제 #3
0
 public static ICryptoTransform CreateEncryptor(this SymmetricAlgorithm symmetricAlgorithm, CryptoKey cryptoKey, CryptoIV cryptoIV)
 {
     return symmetricAlgorithm.CreateEncryptor(cryptoKey.Value, cryptoIV.Value);
 }