Exemplo n.º 1
0
 /// <summary>
 /// Encrypts a stream using the supplied password
 /// </summary>
 /// <param name="password">The password to decrypt with</param>
 /// <param name="input">The stream with unencrypted data</param>
 /// <param name="output">The encrypted output stream</param>
 public static void Encrypt(string password, Stream input, Stream output)
 {
     int a;
     byte[] buffer = new byte[1024 * 4];
     SAE c = new SAE(password, output, OperationMode.Encrypt);
     while ((a = input.Read(buffer, 0, buffer.Length)) != 0)
         c.Write(buffer, 0, a);
     c.FlushFinalBlock();
 }
Exemplo n.º 2
0
 /// <summary>
 /// Decrypts a stream using the supplied password
 /// </summary>
 /// <param name="password">The password to encrypt with</param>
 /// <param name="input">The stream with encrypted data</param>
 /// <param name="output">The unencrypted output stream</param>
 public static void Decrypt(string password, Stream input, Stream output)
 {
     int a;
     byte[] buffer = new byte[1024 * 4];
     SAE c = new SAE(password, input, OperationMode.Decrypt);
     while ((a = c.Read(buffer, 0, buffer.Length)) != 0)
         output.Write(buffer, 0, a);
 }