Ejemplo n.º 1
0
 /// <summary>
 /// File Decryptor
 /// </summary>
 /// <param name="targetStream"></param>
 /// <param name="criptoEngine"></param>
 /// <param name="sourceData"></param>
 public static void Decrypt(Stream targetStream, ref Byte[] fileEncriptedData, int startPosition, byte[] key, byte[] iv)
 {
     // Create a Decryptor
     using (ChaCha20Stream cc = new ChaCha20Stream(targetStream, true, key, iv))
     {
         cc.Write(fileEncriptedData, startPosition, fileEncriptedData.Length - startPosition);
         cc.Flush();
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// File Encryptor
 /// </summary>
 /// <param name="targetStream"></param>
 /// <param name="criptoEngine"></param>
 /// <param name="sourceData"></param>
 public static void Encrypt(Stream targetStream, ref byte[] sourceData, ref byte[] key, ref byte[] iv)
 {
     // Create a Crypto Stream
     using (ChaCha20Stream cc = new ChaCha20Stream(targetStream, true, key, iv))
     {
         cc.Write(sourceData, 0, sourceData.Length);
         cc.Flush();
     }
 }