From b8b3cccc13fe7bc6b83e2667277a499bd88e1251 Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 7 Nov 2019 20:11:25 +0200 Subject: [PATCH] Fixed bug with file saving on app closing --- Crypto Notepad/MainForm.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Crypto Notepad/MainForm.cs b/Crypto Notepad/MainForm.cs index 4de0272..6f03fbd 100644 --- a/Crypto Notepad/MainForm.cs +++ b/Crypto Notepad/MainForm.cs @@ -786,9 +786,10 @@ private void MainWindow_FormClosing(object sender, FormClosingEventArgs e) trayIcon.Visible = false; using (StreamWriter writer = new StreamWriter(filePath)) { - string enc = ""; - Task.Run(async () => { enc = await AES.Encrypt(richTextBox.Text, PublicVar.encryptionKey.Get(), null, settings.HashAlgorithm, Convert.ToInt32(settings.PasswordIterations), Convert.ToInt32(settings.KeySize)); }).Wait(); - writer.Write(enc); + string encryptedText = richTextBox.Text; + Task.Run(async () => { encryptedText = await AES.Encrypt(encryptedText, PublicVar.encryptionKey.Get(), null, settings.HashAlgorithm, + Convert.ToInt32(settings.PasswordIterations), Convert.ToInt32(settings.KeySize)); }).Wait(); + writer.Write(encryptedText); writer.Close(); } }