From b808026465fa907ea3a167e788eab67a30d6d645 Mon Sep 17 00:00:00 2001 From: Alexander Date: Sat, 9 Nov 2019 19:55:53 +0200 Subject: [PATCH] Fixed performance issues on large values of Password iterations when "Save As" #43 --- Crypto Notepad/MainForm.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Crypto Notepad/MainForm.cs b/Crypto Notepad/MainForm.cs index b05edba..0a3f8f0 100644 --- a/Crypto Notepad/MainForm.cs +++ b/Crypto Notepad/MainForm.cs @@ -1174,13 +1174,22 @@ private async void SaveAsMainMenu_Click(object sender, EventArgs e) TypedPassword.Value = PublicVar.encryptionKey.Get(); } filePath = saveFileDialog.FileName; - string enc = await AES.Encrypt(richTextBox.Text, TypedPassword.Value, null, settings.HashAlgorithm, - Convert.ToInt32(settings.PasswordIterations), Convert.ToInt32(settings.KeySize)); + mainMenu.Enabled = false; + toolbarPanel.Enabled = false; + richTextBox.ReadOnly = true; + richTextBox.SuspendDrawing(); + UseWaitCursor = true; using (StreamWriter writer = new StreamWriter(filePath)) { - writer.Write(enc); + writer.Write(await AES.Encrypt(richTextBox.Text, PublicVar.encryptionKey.Get(), null, settings.HashAlgorithm, + Convert.ToInt32(settings.PasswordIterations), Convert.ToInt32(settings.KeySize))); writer.Close(); } + richTextBox.ResumeDrawing(); + UseWaitCursor = false; + mainMenu.Enabled = true; + toolbarPanel.Enabled = true; + richTextBox.ReadOnly = false; richTextBox.Modified = false; Text = PublicVar.appName + " – " + Path.GetFileName(filePath); PublicVar.encryptionKey.Set(TypedPassword.Value);