diff --git a/Crypto Notepad/App.config b/Crypto Notepad/App.config
index 553764f..c102808 100644
--- a/Crypto Notepad/App.config
+++ b/Crypto Notepad/App.config
@@ -162,6 +162,9 @@
10
+
+
+
diff --git a/Crypto Notepad/External Libraries/AES.cs b/Crypto Notepad/External Libraries/AES.cs
index 3488722..e3ba476 100644
--- a/Crypto Notepad/External Libraries/AES.cs
+++ b/Crypto Notepad/External Libraries/AES.cs
@@ -204,16 +204,19 @@ public static async Task Decrypt(string cipherText, string password, str
{
// Metadata parsing error
DialogResult result = MessageBox.Show("Unable to parse file metadata.\nAttempt to open anyway?\n(May result in a \'Incorrect Key\' error if the salt is wrong.)",
- "Missing or Corrupted Metadata", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Asterisk);
+ "Missing or Corrupted Metadata", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
if (result == DialogResult.Yes)
{
// Default initialization vector from builds v1.1.2 and older
const string default_IV = "16CHARSLONG12345";
-
initialVectorBytes = Encoding.ASCII.GetBytes(default_IV);
saltValueBytes = Encoding.ASCII.GetBytes(salt);
}
- else { return null; }
+ else
+ {
+ PublicVar.metadataCorrupt = true;
+ return null;
+ }
}
else
{
diff --git a/Crypto Notepad/Forms/MainForm.cs b/Crypto Notepad/Forms/MainForm.cs
index f6e1ff6..42c037f 100644
--- a/Crypto Notepad/Forms/MainForm.cs
+++ b/Crypto Notepad/Forms/MainForm.cs
@@ -78,8 +78,30 @@ private async Task DecryptAES()
toolbarPanel.Enabled = false;
richTextBox.ReadOnly = true;
string openedFileText = await reader.ReadToEndAsync();
- richTextBox.Text = await AES.Decrypt(openedFileText, TypedPassword.Value, null, settings.HashAlgorithm,
- Convert.ToInt32(settings.PasswordIterations), Convert.ToInt32(settings.KeySize)); ;
+ if (string.IsNullOrEmpty(settings.TheSalt))
+ {
+ richTextBox.Text = await AES.Decrypt(openedFileText, TypedPassword.Value, null, settings.HashAlgorithm,
+ Convert.ToInt32(settings.PasswordIterations), Convert.ToInt32(settings.KeySize));
+ }
+ else
+ {
+ string currentRichTextBoxText = richTextBox.Text;
+ richTextBox.Text = await AES.Decrypt(openedFileText, TypedPassword.Value, settings.TheSalt, settings.HashAlgorithm,
+ Convert.ToInt32(settings.PasswordIterations), Convert.ToInt32(settings.KeySize));
+ if (PublicVar.metadataCorrupt)
+ {
+ PublicVar.openFileName = Path.GetFileName(filePath);
+ PublicVar.metadataCorrupt = false;
+ mainMenu.Enabled = true;
+ toolbarPanel.Enabled = true;
+ richTextBox.ReadOnly = false;
+ UseWaitCursor = false;
+ richTextBox.ResumeDrawing();
+ richTextBox.Text = currentRichTextBoxText;
+ richTextBox.Modified = false;
+ return;
+ }
+ }
}
Text = Path.GetFileName(openFileDialog.FileName) + " – " + PublicVar.appName;
filePath = openFileDialog.FileName;
@@ -1904,6 +1926,7 @@ private void VariablesMainMenu_Click(object sender, EventArgs e)
Debug.WriteLine("okPressed: " + PublicVar.okPressed);
Debug.WriteLine("RichTextBox.Modified: " + richTextBox.Modified);
Debug.WriteLine("EditorMenuStrip: " + contextMenu.Enabled);
+ Debug.WriteLine("metadataCorrupt: " + PublicVar.metadataCorrupt);
#endif
}
#endregion
diff --git a/Crypto Notepad/Program.cs b/Crypto Notepad/Program.cs
index fa586f9..17191a3 100644
--- a/Crypto Notepad/Program.cs
+++ b/Crypto Notepad/Program.cs
@@ -68,6 +68,7 @@ static class PublicVar
public static bool messageBoxCenterParent = false;
public const string appName = "Crypto Notepad";
public static string openFileName;
+ public static bool metadataCorrupt = false;
}
static class TypedPassword
diff --git a/Crypto Notepad/Properties/Settings.Designer.cs b/Crypto Notepad/Properties/Settings.Designer.cs
index f0e42ae..c0c1012 100644
--- a/Crypto Notepad/Properties/Settings.Designer.cs
+++ b/Crypto Notepad/Properties/Settings.Designer.cs
@@ -662,6 +662,7 @@ public string passwordGeneratorLength {
}
[global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Configuration.SettingsProviderAttribute(typeof(PortableSettingsProvider))]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("10")]
public string passwordGeneratorNumberOfStrings {
@@ -672,5 +673,18 @@ public string passwordGeneratorNumberOfStrings {
this["passwordGeneratorNumberOfStrings"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Configuration.SettingsProviderAttribute(typeof(PortableSettingsProvider))]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("")]
+ public string TheSalt {
+ get {
+ return ((string)(this["TheSalt"]));
+ }
+ set {
+ this["TheSalt"] = value;
+ }
+ }
}
}
diff --git a/Crypto Notepad/Properties/Settings.settings b/Crypto Notepad/Properties/Settings.settings
index 7efa56d..7cf14e3 100644
--- a/Crypto Notepad/Properties/Settings.settings
+++ b/Crypto Notepad/Properties/Settings.settings
@@ -149,8 +149,11 @@
40
-
+
10
+
+
+
\ No newline at end of file