Hi could suggest someone or help me optimize the process of filestream?
When I try to decrypt 600MB files it takes about 10mins to finish.
Here's my
CodeTags adjusted ~VaporiZed
When I try to decrypt 600MB files it takes about 10mins to finish.
Here's my
VB.NET-Quellcode
- Private Sub BGW_DoWork(sender As Object, e As DoWorkEventArgs) Handles BGW.DoWork
- Dim newWorer As BackgroundWorker = DirectCast(sender, BackgroundWorker)
- Dim counter As Double = 1
- Dim outputPath As String = txtOuput.Text
- Dim files = Directory.GetFiles(txtInput.Text, "*.ts")
- Dim key As Byte() = File.ReadAllBytes(txtKey.Text)
- Dim IV(15) As Byte
- Using outputStream As FileStream = New FileStream(outputPath, FileMode.Create, FileAccess.Write)
- For i As Integer = 0 To files.Length - 1
- Using inputStream As FileStream = New FileStream(files(i), FileMode.Open, FileAccess.Read, FileShare.Read, FileOptions.SequentialScan)
- Using AES As New AesManaged
- AES.KeySize = 256
- AES.BlockSize = 128
- AES.Key = key
- AES.IV = IV
- AES.Padding = PaddingMode.PKCS7
- AES.Mode = CipherMode.CBC
- Using AESDecrypter As ICryptoTransform = AES.CreateDecryptor(AES.Key, AES.IV)
- Using cryptoStream As CryptoStream = New CryptoStream(inputStream, AESDecrypter, CryptoStreamMode.Read, FileOptions.SequentialScan)
- Dim value As Double = (counter / files.Length) * 100
- newWorer.ReportProgress(value)
- Dim PlaintextBytes(inputStream.Length - 1) As Byte
- cryptoStream.CopyTo(outputStream, PlaintextBytes.Length)
- counter += 1
- cryptoStream.Dispose()
- cryptoStream.Close()
- inputStream.Close()
- inputStream.Dispose()
- End Using
- End Using
- End Using
- End Using
- Next
- outputStream.Close()
- outputStream.Dispose()
- End Using
- End Sub
CodeTags adjusted ~VaporiZed
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „VaporiZed“ ()