0
public void EncryptFile(string input, string output,RijndaelManaged alg1)
        {
            FileStream inputStream = new FileStream(input, FileMode.Open, FileAccess.Read);
            FileStream outputStream = new FileStream(output, FileMode.OpenOrCreate, FileAccess.Write);

            SymmetricAlgorithm alg = new RijndaelManaged();
            alg.Key = alg1.Key;
            alg.IV = alg1.IV;

            byte[] data = new byte[inputStream.Length];
            inputStream.Read(data, 0, (int)data.Length);


            alg.Padding = PaddingMode.PKCS7;

            ICryptoTransform encryptor = alg.CreateEncryptor();
            CryptoStream stream = new CryptoStream(outputStream, encryptor, CryptoStreamMode.Write);

            // WRITE THE DATA ENCRYPTING
            stream.Write(data, 0, data.Length);

            // CLOSE SEGMENT
            stream.Close();
            inputStream.Close();
            outputStream.Close();

        }

This is the algorithm which i use for encrypting file, but if try encrypting a huge video file of size 700 mb , it gives out of memory exception.

so can u please tell me how to read just around 25 mb and encrypt that and next read the next 25mb and encrypt it into same file

2
Contributors
1
Reply
4
Views
7 Years
Discussion Span
Last Post by __avd
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.