System.Security.Cryptography.CryptoStream.Flush C# (CSharp) Method

Flush() public method

public Flush ( ) : void
return void
        public override void Flush()
        {
            return;
        }

Usage Example

Ejemplo n.º 1
0
        public static MemoryStream GetDeCryptedMemoryStream(string outputFilePath, string password = "******")
        {
            var ms = new MemoryStream();

            var inFile = new FileStream(outputFilePath, FileMode.Open, FileAccess.Read);

            var algorithm = GetAlgorithm(password);

            //There could be a case, where more data is appended than required, as a result Serialization fails
            //var length = inFile.Length > 1024 ? 1024 : inFile.Length;
            var length = 1;
            var fileData = new byte[length];

            var encryptedStream = new CryptoStream(inFile, algorithm.CreateDecryptor(), CryptoStreamMode.Read);

            while (encryptedStream.Read(fileData, 0, fileData.Length) != 0)
            {
                ms.Write(fileData, 0, fileData.Length);
            }

            encryptedStream.Flush();
            encryptedStream.Close();
            inFile.Close();

            ms.Position = 0;

            return ms;
        }
All Usage Examples Of System.Security.Cryptography.CryptoStream::Flush