Encryption key renamed to password

This commit is contained in:
Alexander 2019-11-27 11:59:42 +02:00
parent e500c95f5d
commit db405c1e92
7 changed files with 85 additions and 91 deletions

View file

@ -113,7 +113,7 @@ private void InitializeComponent()
//
this.oldKeyTextBox.Location = new System.Drawing.Point(64, 14);
this.oldKeyTextBox.Name = "oldKeyTextBox";
this.oldKeyTextBox.Placeholder = "Old key";
this.oldKeyTextBox.Placeholder = "Old password";
this.oldKeyTextBox.PlaceholderActiveForeColor = System.Drawing.Color.DarkGray;
this.oldKeyTextBox.PlaceholderFont = new System.Drawing.Font("Segoe UI", 8.25F);
this.oldKeyTextBox.PlaceholderForeColor = System.Drawing.Color.DarkGray;
@ -127,7 +127,7 @@ private void InitializeComponent()
//
this.newKeyTextBox.Location = new System.Drawing.Point(64, 39);
this.newKeyTextBox.Name = "newKeyTextBox";
this.newKeyTextBox.Placeholder = "New key";
this.newKeyTextBox.Placeholder = "New password";
this.newKeyTextBox.PlaceholderActiveForeColor = System.Drawing.Color.DarkGray;
this.newKeyTextBox.PlaceholderFont = new System.Drawing.Font("Segoe UI", 8.25F);
this.newKeyTextBox.PlaceholderForeColor = System.Drawing.Color.DarkGray;
@ -140,11 +140,11 @@ private void InitializeComponent()
// statusLabel
//
this.statusLabel.AutoSize = true;
this.statusLabel.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.statusLabel.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.statusLabel.ForeColor = System.Drawing.Color.Black;
this.statusLabel.Location = new System.Drawing.Point(3, 83);
this.statusLabel.Location = new System.Drawing.Point(2, 85);
this.statusLabel.Name = "statusLabel";
this.statusLabel.Size = new System.Drawing.Size(42, 17);
this.statusLabel.Size = new System.Drawing.Size(38, 15);
this.statusLabel.TabIndex = 7;
this.statusLabel.Text = "status";
//
@ -176,7 +176,7 @@ private void InitializeComponent()
this.Name = "ChangeKeyForm";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Change Key";
this.Text = "Change Password";
this.mainPanel.ResumeLayout(false);
this.mainPanel.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.lockPictureBox)).EndInit();

View file

@ -18,22 +18,22 @@ public ChangeKeyForm()
private async void AcceptButton_Click(object sender, EventArgs e)
{
oldKeyTextBox.Focus();
if (oldKeyTextBox.Text == PublicVar.encryptionKey.Get() & oldKeyTextBox.Text != newKeyTextBox.Text)
if (oldKeyTextBox.Text == PublicVar.password.Get() & oldKeyTextBox.Text != newKeyTextBox.Text)
{
PublicVar.encryptionKey.Set(newKeyTextBox.Text);
PublicVar.keyChanged = true;
PublicVar.password.Set(newKeyTextBox.Text);
PublicVar.passwordChanged = true;
statusLabel.ForeColor = Color.Green;
statusLabel.Text = "Key was successfully changed";
statusLabel.Text = "Password was successfully changed";
oldKeyTextBox.Text = "";
newKeyTextBox.Text = "";
await Task.Delay(3000);
statusLabel.Text = "";
}
else if (oldKeyTextBox.Text != PublicVar.encryptionKey.Get())
else if (oldKeyTextBox.Text != PublicVar.password.Get())
{
SystemSounds.Hand.Play();
statusLabel.ForeColor = Color.Red;
statusLabel.Text = "Invalid old key";
statusLabel.Text = "Invalid old password";
oldKeyTextBox.Text = "";
newKeyTextBox.Text = "";
await Task.Delay(2000);
@ -43,7 +43,7 @@ private async void AcceptButton_Click(object sender, EventArgs e)
{
SystemSounds.Hand.Play();
statusLabel.ForeColor = Color.Red;
statusLabel.Text = "New key is the same as old";
statusLabel.Text = "New password is the same as old";
oldKeyTextBox.Text = "";
newKeyTextBox.Text = "";
await Task.Delay(2000);

View file

@ -138,18 +138,12 @@
<metadata name="newKeyTextBox.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="statusLabel.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="changeKeyFormToolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="passwordGeneratorButton.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>

View file

@ -32,15 +32,15 @@ private void InitializeComponent()
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EnterKeyForm));
this.okButton = new System.Windows.Forms.Button();
this.mainPanel = new System.Windows.Forms.Panel();
this.fileNameLabel = new System.Windows.Forms.Label();
this.showKeyPictureBox = new System.Windows.Forms.PictureBox();
this.lockPictureBox = new System.Windows.Forms.PictureBox();
this.fileNameLabel = new System.Windows.Forms.Label();
this.keyTextBox = new System.Windows.Forms.PlaceholderTextBox();
this.showKeyPictureBox = new System.Windows.Forms.PictureBox();
this.enterKeyFormToolTip = new System.Windows.Forms.ToolTip(this.components);
this.passwordGeneratorButton = new System.Windows.Forms.Button();
this.keyTextBox = new System.Windows.Forms.PlaceholderTextBox();
this.mainPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.showKeyPictureBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.lockPictureBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.showKeyPictureBox)).BeginInit();
this.SuspendLayout();
//
// okButton
@ -67,6 +67,18 @@ private void InitializeComponent()
this.mainPanel.Size = new System.Drawing.Size(295, 75);
this.mainPanel.TabIndex = 5;
//
// lockPictureBox
//
this.lockPictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lockPictureBox.Cursor = System.Windows.Forms.Cursors.Default;
this.lockPictureBox.Image = global::Crypto_Notepad.Properties.Resources.key_solid;
this.lockPictureBox.Location = new System.Drawing.Point(8, 14);
this.lockPictureBox.Name = "lockPictureBox";
this.lockPictureBox.Size = new System.Drawing.Size(47, 47);
this.lockPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
this.lockPictureBox.TabIndex = 6;
this.lockPictureBox.TabStop = false;
//
// fileNameLabel
//
this.fileNameLabel.AutoEllipsis = true;
@ -77,6 +89,20 @@ private void InitializeComponent()
this.fileNameLabel.Text = "File name";
this.fileNameLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// keyTextBox
//
this.keyTextBox.Location = new System.Drawing.Point(64, 39);
this.keyTextBox.Name = "keyTextBox";
this.keyTextBox.Placeholder = "Password";
this.keyTextBox.PlaceholderActiveForeColor = System.Drawing.Color.DarkGray;
this.keyTextBox.PlaceholderFont = new System.Drawing.Font("Segoe UI", 8.25F);
this.keyTextBox.PlaceholderForeColor = System.Drawing.Color.DarkGray;
this.keyTextBox.Size = new System.Drawing.Size(206, 22);
this.keyTextBox.TabIndex = 0;
this.keyTextBox.UseSystemPasswordChar = true;
this.keyTextBox.TextChanged += new System.EventHandler(this.KeyTextBox_TextChanged);
this.keyTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.KeyTextBox_KeyDown);
//
// showKeyPictureBox
//
this.showKeyPictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
@ -91,18 +117,6 @@ private void InitializeComponent()
this.showKeyPictureBox.TabStop = false;
this.showKeyPictureBox.Click += new System.EventHandler(this.ShowKeyPictureBox_Click);
//
// lockPictureBox
//
this.lockPictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lockPictureBox.Cursor = System.Windows.Forms.Cursors.Default;
this.lockPictureBox.Image = global::Crypto_Notepad.Properties.Resources.key_solid;
this.lockPictureBox.Location = new System.Drawing.Point(8, 14);
this.lockPictureBox.Name = "lockPictureBox";
this.lockPictureBox.Size = new System.Drawing.Size(47, 47);
this.lockPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
this.lockPictureBox.TabIndex = 6;
this.lockPictureBox.TabStop = false;
//
// passwordGeneratorButton
//
this.passwordGeneratorButton.Image = global::Crypto_Notepad.Properties.Resources.key_plus;
@ -114,20 +128,6 @@ private void InitializeComponent()
this.passwordGeneratorButton.UseVisualStyleBackColor = true;
this.passwordGeneratorButton.Click += new System.EventHandler(this.PasswordGeneratorButton_Click);
//
// keyTextBox
//
this.keyTextBox.Location = new System.Drawing.Point(64, 39);
this.keyTextBox.Name = "keyTextBox";
this.keyTextBox.Placeholder = "Encryption key";
this.keyTextBox.PlaceholderActiveForeColor = System.Drawing.Color.DarkGray;
this.keyTextBox.PlaceholderFont = new System.Drawing.Font("Segoe UI", 8.25F);
this.keyTextBox.PlaceholderForeColor = System.Drawing.Color.DarkGray;
this.keyTextBox.Size = new System.Drawing.Size(206, 22);
this.keyTextBox.TabIndex = 0;
this.keyTextBox.UseSystemPasswordChar = true;
this.keyTextBox.TextChanged += new System.EventHandler(this.KeyTextBox_TextChanged);
this.keyTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.KeyTextBox_KeyDown);
//
// EnterKeyForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -142,14 +142,14 @@ private void InitializeComponent()
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "EnterKeyForm";
this.Text = "Enter encryption key";
this.Text = "Crypto Notepad";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.EnterKeyForm_FormClosed);
this.Load += new System.EventHandler(this.EnterKeyForm_Load);
this.Shown += new System.EventHandler(this.EnterKeyForm_Shown);
this.mainPanel.ResumeLayout(false);
this.mainPanel.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.showKeyPictureBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.lockPictureBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.showKeyPictureBox)).EndInit();
this.ResumeLayout(false);
}

View file

@ -413,7 +413,7 @@ public void InitializeComponent()
this.alwaysOnTopMainMenu.CheckOnClick = true;
this.alwaysOnTopMainMenu.Name = "alwaysOnTopMainMenu";
this.alwaysOnTopMainMenu.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.T)));
this.alwaysOnTopMainMenu.Size = new System.Drawing.Size(220, 22);
this.alwaysOnTopMainMenu.Size = new System.Drawing.Size(261, 22);
this.alwaysOnTopMainMenu.Text = "Always on Top";
this.alwaysOnTopMainMenu.Click += new System.EventHandler(this.AlwaysOnTopMainMenu_Click);
//
@ -421,7 +421,7 @@ public void InitializeComponent()
//
this.passwordGeneratorMainMenu.Name = "passwordGeneratorMainMenu";
this.passwordGeneratorMainMenu.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.P)));
this.passwordGeneratorMainMenu.Size = new System.Drawing.Size(220, 22);
this.passwordGeneratorMainMenu.Size = new System.Drawing.Size(261, 22);
this.passwordGeneratorMainMenu.Text = "Password Generator";
this.passwordGeneratorMainMenu.Click += new System.EventHandler(this.PasswordGeneratorMainMenu_Click);
//
@ -430,15 +430,15 @@ public void InitializeComponent()
this.changeKeyMainMenu.Name = "changeKeyMainMenu";
this.changeKeyMainMenu.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Alt)
| System.Windows.Forms.Keys.K)));
this.changeKeyMainMenu.Size = new System.Drawing.Size(220, 22);
this.changeKeyMainMenu.Text = "Change Key";
this.changeKeyMainMenu.Size = new System.Drawing.Size(232, 22);
this.changeKeyMainMenu.Text = "Change Password";
this.changeKeyMainMenu.Click += new System.EventHandler(this.ChangeKeyMainMenu_Click);
//
// lockMainMenu
//
this.lockMainMenu.Name = "lockMainMenu";
this.lockMainMenu.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.L)));
this.lockMainMenu.Size = new System.Drawing.Size(220, 22);
this.lockMainMenu.Size = new System.Drawing.Size(261, 22);
this.lockMainMenu.Text = "Lock";
this.lockMainMenu.Click += new System.EventHandler(this.LockMainMenu_Click);
//
@ -448,7 +448,7 @@ public void InitializeComponent()
this.settingsMainMenu.ShortcutKeyDisplayString = "";
this.settingsMainMenu.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Alt)
| System.Windows.Forms.Keys.S)));
this.settingsMainMenu.Size = new System.Drawing.Size(220, 22);
this.settingsMainMenu.Size = new System.Drawing.Size(261, 22);
this.settingsMainMenu.Text = "Settings";
this.settingsMainMenu.Click += new System.EventHandler(this.SettingsMainMenu_Click);
//
@ -833,7 +833,7 @@ public void InitializeComponent()
this.changeKeyToolbarButton.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.changeKeyToolbarButton.TabIndex = 15;
this.changeKeyToolbarButton.TabStop = false;
this.toolTip.SetToolTip(this.changeKeyToolbarButton, "Change key");
this.toolTip.SetToolTip(this.changeKeyToolbarButton, "Change password");
this.changeKeyToolbarButton.Click += new System.EventHandler(this.ChangeKeyToolbarButton_Click);
//
// openToolbarButton
@ -959,7 +959,7 @@ public void InitializeComponent()
this.alwaysOnTopToolbarButton.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.alwaysOnTopToolbarButton.TabIndex = 15;
this.alwaysOnTopToolbarButton.TabStop = false;
this.toolTip.SetToolTip(this.alwaysOnTopToolbarButton, "Always on Top");
this.toolTip.SetToolTip(this.alwaysOnTopToolbarButton, "Always on top");
this.alwaysOnTopToolbarButton.Click += new System.EventHandler(this.AlwaysOnTopToolbarButton_Click);
//
// statusPanel
@ -1128,7 +1128,7 @@ public void InitializeComponent()
//
this.fileLockedKeyTextBox.Location = new System.Drawing.Point(6, 34);
this.fileLockedKeyTextBox.Name = "fileLockedKeyTextBox";
this.fileLockedKeyTextBox.Placeholder = "Encryption key";
this.fileLockedKeyTextBox.Placeholder = "Password";
this.fileLockedKeyTextBox.PlaceholderActiveForeColor = System.Drawing.Color.DarkGray;
this.fileLockedKeyTextBox.PlaceholderFont = new System.Drawing.Font("Segoe UI", 8.25F);
this.fileLockedKeyTextBox.PlaceholderForeColor = System.Drawing.Color.DarkGray;

View file

@ -36,7 +36,7 @@ protected override void WndProc(ref Message m)
const int SC_MINIMIZE = 0xF020;
try
{
if (m.Msg == WM_SYSCOMMAND & m.WParam.ToInt32() == SC_MINIMIZE & settings.autoLock & !string.IsNullOrEmpty(PublicVar.encryptionKey.Get()))
if (m.Msg == WM_SYSCOMMAND & m.WParam.ToInt32() == SC_MINIMIZE & settings.autoLock & !string.IsNullOrEmpty(PublicVar.password.Get()))
{
richTextBox.Visible = false;
}
@ -106,7 +106,7 @@ private async Task DecryptAES()
Text = Path.GetFileName(openFileDialog.FileName) + " " + PublicVar.appName;
filePath = openFileDialog.FileName;
PublicVar.openFileName = Path.GetFileName(openFileDialog.FileName);
PublicVar.encryptionKey.Set(TypedPassword.Value);
PublicVar.password.Set(TypedPassword.Value);
TypedPassword.Value = null;
StatusPanelFileInfo();
mainMenu.Enabled = true;
@ -227,7 +227,7 @@ private async void ContextMenuEncryptReplace()
writer.Write(encryptedText);
writer.Close();
}
PublicVar.encryptionKey.Set(TypedPassword.Value);
PublicVar.password.Set(TypedPassword.Value);
TypedPassword.Value = null;
filePath = newFileName;
PublicVar.openFileName = Path.GetFileName(newFileName);
@ -246,7 +246,7 @@ private void SaveConfirm()
{
PublicVar.openFileName = "Unnamed.cnp";
}
if (!PublicVar.keyChanged)
if (!PublicVar.passwordChanged)
{
messageBoxText = "Save file: " + "\"" + PublicVar.openFileName + "\"" + " ? ";
}
@ -469,7 +469,7 @@ private async Task UnlockFile()
richTextBox.Modified = false;
fileLockedPanel.Visible = false;
richTextBox.SelectionStart = caretPos;
PublicVar.encryptionKey.Set(TypedPassword.Value);
PublicVar.password.Set(TypedPassword.Value);
TypedPassword.Value = null;
richTextBox.Focus();
StatusPanelFileInfo();
@ -690,7 +690,7 @@ private void MainForm_Resize(object sender, EventArgs e)
Hide();
}
}
if (WindowState == FormWindowState.Minimized & settings.autoLock & !string.IsNullOrEmpty(PublicVar.encryptionKey.Get()))
if (WindowState == FormWindowState.Minimized & settings.autoLock & !string.IsNullOrEmpty(PublicVar.password.Get()))
{
fileLockedPanel.Visible = true;
}
@ -707,7 +707,7 @@ private void MainWindow_Activated(object sender, EventArgs e)
{
richTextBox.Focus();
if (PublicVar.keyChanged)
if (PublicVar.passwordChanged)
{
richTextBox.Modified = true;
}
@ -730,7 +730,7 @@ private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
if (settings.autoLock & !string.IsNullOrEmpty(PublicVar.encryptionKey.Get()))
if (settings.autoLock & !string.IsNullOrEmpty(PublicVar.password.Get()))
{
fileLockedPanel.Visible = true;
}
@ -748,13 +748,13 @@ private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
if (!string.IsNullOrEmpty(richTextBox.Text))
{
string messageBoxText;
if (!PublicVar.keyChanged)
if (!PublicVar.passwordChanged)
{
messageBoxText = "Save file: " + "\"" + PublicVar.openFileName + "\"" + " ? ";
}
else
{
messageBoxText = "Save file: " + "\"" + PublicVar.openFileName + "\"" + " with a new key? ";
messageBoxText = "Save file: " + "\"" + PublicVar.openFileName + "\"" + " with a new password? ";
}
if (Visible)
{
@ -788,7 +788,7 @@ private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
e.Cancel = true;
return;
}
PublicVar.encryptionKey.Set(TypedPassword.Value);
PublicVar.password.Set(TypedPassword.Value);
filePath = saveFileDialog.FileName;
}
Hide();
@ -796,7 +796,7 @@ private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
using (StreamWriter writer = new StreamWriter(filePath))
{
string encryptedText = richTextBox.Text;
Task.Run(async () => { encryptedText = await AES.Encrypt(encryptedText, PublicVar.encryptionKey.Get(), null, settings.HashAlgorithm,
Task.Run(async () => { encryptedText = await AES.Encrypt(encryptedText, PublicVar.password.Get(), null, settings.HashAlgorithm,
Convert.ToInt32(settings.PasswordIterations), Convert.ToInt32(settings.KeySize)); }).Wait();
writer.Write(encryptedText);
writer.Close();
@ -1051,7 +1051,7 @@ private void NewMainMenu_Click(object sender, EventArgs e)
return;
}
richTextBox.Clear();
PublicVar.encryptionKey.Set(TypedPassword.Value);
PublicVar.password.Set(TypedPassword.Value);
StreamWriter sw = new StreamWriter(saveFileDialog.FileName);
Text = Path.GetFileName(saveFileDialog.FileName) + " " + PublicVar.appName;
filePath = saveFileDialog.FileName;
@ -1100,7 +1100,7 @@ private async void OpenMainMenu_Click(object sender, EventArgs e)
private async void SaveMainMenu_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(PublicVar.encryptionKey.Get()))
if (string.IsNullOrEmpty(PublicVar.password.Get()))
{
SaveAsMainMenu_Click(this, new EventArgs());
return;
@ -1112,12 +1112,12 @@ private async void SaveMainMenu_Click(object sender, EventArgs e)
UseWaitCursor = true;
using (StreamWriter writer = new StreamWriter(filePath))
{
writer.Write(await AES.Encrypt(richTextBox.Text, PublicVar.encryptionKey.Get(), null, settings.HashAlgorithm,
writer.Write(await AES.Encrypt(richTextBox.Text, PublicVar.password.Get(), null, settings.HashAlgorithm,
Convert.ToInt32(settings.PasswordIterations), Convert.ToInt32(settings.KeySize)));
writer.Close();
}
richTextBox.Modified = false;
PublicVar.keyChanged = false;
PublicVar.passwordChanged = false;
StatusPanelMessage("save");
StatusPanelFileInfo();
richTextBox.ResumeDrawing();
@ -1148,7 +1148,7 @@ private async void SaveAsMainMenu_Click(object sender, EventArgs e)
{
Owner = this
};
if (string.IsNullOrEmpty(PublicVar.encryptionKey.Get()))
if (string.IsNullOrEmpty(PublicVar.password.Get()))
{
enterKeyForm.ShowDialog();
if (!PublicVar.okPressed)
@ -1159,9 +1159,9 @@ private async void SaveAsMainMenu_Click(object sender, EventArgs e)
}
if (TypedPassword.Value == null)
{
TypedPassword.Value = PublicVar.encryptionKey.Get();
TypedPassword.Value = PublicVar.password.Get();
}
PublicVar.encryptionKey.Set(TypedPassword.Value);
PublicVar.password.Set(TypedPassword.Value);
filePath = saveFileDialog.FileName;
mainMenu.Enabled = false;
toolbarPanel.Enabled = false;
@ -1170,7 +1170,7 @@ private async void SaveAsMainMenu_Click(object sender, EventArgs e)
UseWaitCursor = true;
using (StreamWriter writer = new StreamWriter(filePath))
{
writer.Write(await AES.Encrypt(richTextBox.Text, PublicVar.encryptionKey.Get(), null, settings.HashAlgorithm,
writer.Write(await AES.Encrypt(richTextBox.Text, PublicVar.password.Get(), null, settings.HashAlgorithm,
Convert.ToInt32(settings.PasswordIterations), Convert.ToInt32(settings.KeySize)));
writer.Close();
}
@ -1195,7 +1195,7 @@ private async void SaveCloseFileMainMenu_Click(object sender, EventArgs e)
UseWaitCursor = true;
using (StreamWriter writer = new StreamWriter(filePath))
{
writer.Write(await AES.Encrypt(richTextBox.Text, PublicVar.encryptionKey.Get(), null, settings.HashAlgorithm,
writer.Write(await AES.Encrypt(richTextBox.Text, PublicVar.password.Get(), null, settings.HashAlgorithm,
Convert.ToInt32(settings.PasswordIterations), Convert.ToInt32(settings.KeySize)));
writer.Close();
}
@ -1204,7 +1204,7 @@ private async void SaveCloseFileMainMenu_Click(object sender, EventArgs e)
mainMenu.Enabled = true;
toolbarPanel.Enabled = true;
richTextBox.ReadOnly = false;
PublicVar.encryptionKey.Set(null);
PublicVar.password.Set(null);
richTextBox.Clear();
PublicVar.openFileName = "";
filePath = "";
@ -1231,7 +1231,7 @@ private void DeleteFileToolStripMenuItem_Click(object sender, EventArgs e)
{
File.Delete(filePath);
richTextBox.Clear();
PublicVar.encryptionKey.Set(null);
PublicVar.password.Set(null);
fileLocationToolbarButton.Enabled = false;
deleteFileToolbarButton.Enabled = false;
changeKeyToolbarButton.Enabled = false;
@ -1403,7 +1403,7 @@ private void PasswordGeneratorMainMenu_Click(object sender, EventArgs e)
private void ToolsMainMenu_DropDownOpened(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(PublicVar.encryptionKey.Get()))
if (string.IsNullOrEmpty(PublicVar.password.Get()))
{
changeKeyMainMenu.Enabled = false;
lockMainMenu.Enabled = false;
@ -1429,7 +1429,7 @@ private async void LockMainMenu_Click(object sender, EventArgs e)
UseWaitCursor = true;
using (StreamWriter writer = new StreamWriter(filePath))
{
writer.Write(await AES.Encrypt(richTextBox.Text, PublicVar.encryptionKey.Get(), null, settings.HashAlgorithm,
writer.Write(await AES.Encrypt(richTextBox.Text, PublicVar.password.Get(), null, settings.HashAlgorithm,
Convert.ToInt32(settings.PasswordIterations), Convert.ToInt32(settings.KeySize)));
writer.Close();
}
@ -1662,7 +1662,7 @@ private void ToolbarPanel_MouseEnter(object sender, EventArgs e)
copyToolbarButton.Enabled = false;
}
if (string.IsNullOrEmpty(PublicVar.encryptionKey.Get()))
if (string.IsNullOrEmpty(PublicVar.password.Get()))
{
fileLocationToolbarButton.Enabled = false;
deleteFileToolbarButton.Enabled = false;
@ -1809,7 +1809,7 @@ private void FileLockedPanel_VisibleChanged(object sender, EventArgs e)
searchTextBox.Text = "";
searchPanel.Visible = false;
}
PublicVar.encryptionKey.Set(null);
PublicVar.password.Set(null);
caretPos = richTextBox.SelectionStart;
richTextBox.Visible = false;
toolbarPanel.Enabled = false;
@ -1920,9 +1920,9 @@ private void VariablesMainMenu_Click(object sender, EventArgs e)
Debug.WriteLine("\nTime: " + formattedTime);
Debug.WriteLine("PublicVar.openFileName: " + PublicVar.openFileName);
Debug.WriteLine("filePath: " + filePath);
Debug.WriteLine("encryptionKey: " + PublicVar.encryptionKey.Get());
Debug.WriteLine("encryptionKey: " + PublicVar.password.Get());
Debug.WriteLine("TypedPassword: " + TypedPassword.Value);
Debug.WriteLine("keyChanged: " + PublicVar.keyChanged);
Debug.WriteLine("keyChanged: " + PublicVar.passwordChanged);
Debug.WriteLine("okPressed: " + PublicVar.okPressed);
Debug.WriteLine("RichTextBox.Modified: " + richTextBox.Modified);
Debug.WriteLine("EditorMenuStrip: " + contextMenu.Enabled);

View file

@ -62,8 +62,8 @@ static void Main()
static class PublicVar
{
public static EncryptedString encryptionKey = new EncryptedString();
public static bool keyChanged = false;
public static EncryptedString password = new EncryptedString();
public static bool passwordChanged = false;
public static bool okPressed = false;
public static bool messageBoxCenterParent = false;
public const string appName = "Crypto Notepad";