mirror of
https://github.com/Crypto-Notepad/Crypto-Notepad.git
synced 2026-03-11 08:55:25 +00:00
key var renamed to encryptionKey
This commit is contained in:
parent
c08462ab91
commit
126fcf5aec
2 changed files with 20 additions and 21 deletions
|
|
@ -13,9 +13,9 @@ public ChangeKeyForm()
|
||||||
|
|
||||||
private async void button1_Click(object sender, EventArgs e)
|
private async void button1_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (textBox1.Text == MainWindow.key & textBox1.Text != textBox2.Text)
|
if (textBox1.Text == MainWindow.encryptionKey & textBox1.Text != textBox2.Text)
|
||||||
{
|
{
|
||||||
MainWindow.key = textBox2.Text;
|
MainWindow.encryptionKey = textBox2.Text;
|
||||||
MainWindow.keyChanged = true;
|
MainWindow.keyChanged = true;
|
||||||
textBox1.Text = "";
|
textBox1.Text = "";
|
||||||
textBox2.Text = "";
|
textBox2.Text = "";
|
||||||
|
|
@ -27,7 +27,7 @@ private async void button1_Click(object sender, EventArgs e)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (textBox1.Text != MainWindow.key)
|
if (textBox1.Text != MainWindow.encryptionKey)
|
||||||
{
|
{
|
||||||
statusLabel.Text = "Invalid old key!";
|
statusLabel.Text = "Invalid old key!";
|
||||||
statusLabel.Visible = true;
|
statusLabel.Visible = true;
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ void DecryptAES()
|
||||||
{
|
{
|
||||||
string opnfile = File.ReadAllText(OpenFile.FileName);
|
string opnfile = File.ReadAllText(OpenFile.FileName);
|
||||||
string NameWithotPath = Path.GetFileName(OpenFile.FileName);
|
string NameWithotPath = Path.GetFileName(OpenFile.FileName);
|
||||||
string de = AES.Decrypt(opnfile, key, ps.TheSalt, ps.HashAlgorithm, ps.PasswordIterations, "16CHARSLONG12345", ps.KeySize);
|
string de = AES.Decrypt(opnfile, encryptionKey, ps.TheSalt, ps.HashAlgorithm, ps.PasswordIterations, "16CHARSLONG12345", ps.KeySize);
|
||||||
customRTB.Text = de;
|
customRTB.Text = de;
|
||||||
|
|
||||||
this.Text = appName + " - " + NameWithotPath;
|
this.Text = appName + " - " + NameWithotPath;
|
||||||
|
|
@ -145,7 +145,7 @@ private void openAsotiations()
|
||||||
}
|
}
|
||||||
Form2.OkPressed = false;
|
Form2.OkPressed = false;
|
||||||
|
|
||||||
string de = AES.Decrypt(opnfile, key, ps.TheSalt, ps.HashAlgorithm, ps.PasswordIterations, "16CHARSLONG12345", ps.KeySize);
|
string de = AES.Decrypt(opnfile, encryptionKey, ps.TheSalt, ps.HashAlgorithm, ps.PasswordIterations, "16CHARSLONG12345", ps.KeySize);
|
||||||
customRTB.Text = de;
|
customRTB.Text = de;
|
||||||
|
|
||||||
this.Text = appName + " - " + NameWithotPath;
|
this.Text = appName + " - " + NameWithotPath;
|
||||||
|
|
@ -196,7 +196,7 @@ private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
string NameWithotPath = Path.GetFileName(OpenFile.FileName);
|
string NameWithotPath = Path.GetFileName(OpenFile.FileName);
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(key))
|
if (string.IsNullOrEmpty(encryptionKey))
|
||||||
{
|
{
|
||||||
Form2 Form2 = new Form2();
|
Form2 Form2 = new Form2();
|
||||||
Form2.ShowDialog();
|
Form2.ShowDialog();
|
||||||
|
|
@ -215,7 +215,7 @@ private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
filename = SaveFile.FileName;
|
filename = SaveFile.FileName;
|
||||||
|
|
||||||
string noenc = customRTB.Text;
|
string noenc = customRTB.Text;
|
||||||
string en = AES.Encrypt(customRTB.Text, key, ps.TheSalt, ps.HashAlgorithm, ps.PasswordIterations, "16CHARSLONG12345", ps.KeySize);
|
string en = AES.Encrypt(customRTB.Text, encryptionKey, ps.TheSalt, ps.HashAlgorithm, ps.PasswordIterations, "16CHARSLONG12345", ps.KeySize);
|
||||||
customRTB.Text = en;
|
customRTB.Text = en;
|
||||||
StreamWriter sw = new StreamWriter(filename);
|
StreamWriter sw = new StreamWriter(filename);
|
||||||
int i = customRTB.Lines.Count();
|
int i = customRTB.Lines.Count();
|
||||||
|
|
@ -280,7 +280,7 @@ private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
{
|
{
|
||||||
messageBoxText = "Save file: " + "\"" + NameWithotPath + "\"" + " with a new key? ";
|
messageBoxText = "Save file: " + "\"" + NameWithotPath + "\"" + " with a new key? ";
|
||||||
}
|
}
|
||||||
//Save file with a new key?
|
|
||||||
using (new CenterWinDialog(this))
|
using (new CenterWinDialog(this))
|
||||||
{
|
{
|
||||||
res = MessageBox.Show(messageBoxText, "Crypto Notepad",
|
res = MessageBox.Show(messageBoxText, "Crypto Notepad",
|
||||||
|
|
@ -414,7 +414,7 @@ private void saveToolStripMenuItem1_Click_1(object sender, EventArgs e)
|
||||||
}
|
}
|
||||||
|
|
||||||
string noenc = customRTB.Text;
|
string noenc = customRTB.Text;
|
||||||
string en = AES.Encrypt(customRTB.Text, key, ps.TheSalt, ps.HashAlgorithm, ps.PasswordIterations, "16CHARSLONG12345", ps.KeySize);
|
string en = AES.Encrypt(customRTB.Text, encryptionKey, ps.TheSalt, ps.HashAlgorithm, ps.PasswordIterations, "16CHARSLONG12345", ps.KeySize);
|
||||||
customRTB.Text = en;
|
customRTB.Text = en;
|
||||||
StreamWriter sw = new StreamWriter(filename);
|
StreamWriter sw = new StreamWriter(filename);
|
||||||
int i = customRTB.Lines.Count();
|
int i = customRTB.Lines.Count();
|
||||||
|
|
@ -496,7 +496,7 @@ private void deleteFileToolStripMenuItem_Click_1(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
File.Delete(filename);
|
File.Delete(filename);
|
||||||
customRTB.Clear();
|
customRTB.Clear();
|
||||||
key = "";
|
encryptionKey = "";
|
||||||
pictureBox11.Enabled = false;
|
pictureBox11.Enabled = false;
|
||||||
filename = "Unnamed.cnp";
|
filename = "Unnamed.cnp";
|
||||||
this.Text = appName;
|
this.Text = appName;
|
||||||
|
|
@ -703,13 +703,13 @@ private void MainWindow_Activated(object sender, EventArgs e)
|
||||||
customRTB.Modified = true;
|
customRTB.Modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key == "")
|
if (encryptionKey == "")
|
||||||
{
|
{
|
||||||
pictureBox11.Enabled = false;
|
pictureBox11.Enabled = false;
|
||||||
pictureBox13.Enabled = false;
|
pictureBox13.Enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key != "")
|
if (encryptionKey != "")
|
||||||
{
|
{
|
||||||
pictureBox11.Enabled = true;
|
pictureBox11.Enabled = true;
|
||||||
pictureBox13.Enabled = true;
|
pictureBox13.Enabled = true;
|
||||||
|
|
@ -737,7 +737,6 @@ private void findToolStripMenuItem2_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
panel1.Visible = true;
|
panel1.Visible = true;
|
||||||
searchTextBox.Focus();
|
searchTextBox.Focus();
|
||||||
//SendMessage(customRTB.Handle, (uint)0x00B6, (UIntPtr)0, (IntPtr)(-1));
|
|
||||||
customRTB.Height = customRTB.Height - 27;
|
customRTB.Height = customRTB.Height - 27;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -748,7 +747,6 @@ private void findToolStripMenuItem2_Click(object sender, EventArgs e)
|
||||||
panel1.Visible = false;
|
panel1.Visible = false;
|
||||||
customRTB.Height = customRTB.Height += 27;
|
customRTB.Height = customRTB.Height += 27;
|
||||||
customRTB.Focus();
|
customRTB.Focus();
|
||||||
//SendMessage(customRTB.Handle, (uint)0x00B6, (UIntPtr)0, (IntPtr)(1));
|
|
||||||
customRTB.DeselectAll();
|
customRTB.DeselectAll();
|
||||||
customRTB.SelectionStart = caretPos;
|
customRTB.SelectionStart = caretPos;
|
||||||
return;
|
return;
|
||||||
|
|
@ -762,13 +760,13 @@ private void documentationToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
|
||||||
private void сервисToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
private void сервисToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (key == "")
|
if (encryptionKey == "")
|
||||||
{
|
{
|
||||||
changeKeyToolStripMenuItem.Enabled = false;
|
changeKeyToolStripMenuItem.Enabled = false;
|
||||||
lockToolStripMenuItem.Enabled = false;
|
lockToolStripMenuItem.Enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key != "")
|
if (encryptionKey != "")
|
||||||
{
|
{
|
||||||
changeKeyToolStripMenuItem.Enabled = true;
|
changeKeyToolStripMenuItem.Enabled = true;
|
||||||
lockToolStripMenuItem.Enabled = true;
|
lockToolStripMenuItem.Enabled = true;
|
||||||
|
|
@ -929,7 +927,7 @@ private void pictureBox1_MouseLeave(object sender, EventArgs e)
|
||||||
void AutoLock(bool minimize)
|
void AutoLock(bool minimize)
|
||||||
{
|
{
|
||||||
Form2 f2 = new Form2();
|
Form2 f2 = new Form2();
|
||||||
key = "";
|
encryptionKey = "";
|
||||||
caretPos = customRTB.SelectionStart;
|
caretPos = customRTB.SelectionStart;
|
||||||
this.Hide();
|
this.Hide();
|
||||||
if (minimize == true)
|
if (minimize == true)
|
||||||
|
|
@ -940,7 +938,7 @@ void AutoLock(bool minimize)
|
||||||
|
|
||||||
if (Form2.OkPressed == false)
|
if (Form2.OkPressed == false)
|
||||||
{
|
{
|
||||||
key = "";
|
encryptionKey = "";
|
||||||
customRTB.Clear();
|
customRTB.Clear();
|
||||||
this.Text = appName;
|
this.Text = appName;
|
||||||
OpenFile.FileName = "";
|
OpenFile.FileName = "";
|
||||||
|
|
@ -954,7 +952,7 @@ void AutoLock(bool minimize)
|
||||||
OpenFile.FileName = filename;
|
OpenFile.FileName = filename;
|
||||||
string opnfile = File.ReadAllText(OpenFile.FileName);
|
string opnfile = File.ReadAllText(OpenFile.FileName);
|
||||||
string NameWithotPath = Path.GetFileName(OpenFile.FileName);
|
string NameWithotPath = Path.GetFileName(OpenFile.FileName);
|
||||||
string de = AES.Decrypt(opnfile, key, ps.TheSalt, ps.HashAlgorithm, ps.PasswordIterations, "16CHARSLONG12345", ps.KeySize);
|
string de = AES.Decrypt(opnfile, encryptionKey, ps.TheSalt, ps.HashAlgorithm, ps.PasswordIterations, "16CHARSLONG12345", ps.KeySize);
|
||||||
|
|
||||||
this.Text = appName + " - " + NameWithotPath;
|
this.Text = appName + " - " + NameWithotPath;
|
||||||
filename = OpenFile.FileName;
|
filename = OpenFile.FileName;
|
||||||
|
|
@ -972,7 +970,7 @@ void AutoLock(bool minimize)
|
||||||
}
|
}
|
||||||
if (dialogResult == DialogResult.Cancel)
|
if (dialogResult == DialogResult.Cancel)
|
||||||
{
|
{
|
||||||
key = "";
|
encryptionKey = "";
|
||||||
customRTB.Clear();
|
customRTB.Clear();
|
||||||
this.Text = appName;
|
this.Text = appName;
|
||||||
OpenFile.FileName = "";
|
OpenFile.FileName = "";
|
||||||
|
|
@ -988,7 +986,7 @@ protected override void WndProc(ref Message m)
|
||||||
const int WM_SYSCOMMAND = 0x112;
|
const int WM_SYSCOMMAND = 0x112;
|
||||||
const int SC_MINIMIZE = 0xF020;
|
const int SC_MINIMIZE = 0xF020;
|
||||||
|
|
||||||
if (m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_MINIMIZE && ps.AutoLock == true && key != "")
|
if (m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_MINIMIZE && ps.AutoLock == true && encryptionKey != "")
|
||||||
{
|
{
|
||||||
AutoLock(true);
|
AutoLock(true);
|
||||||
return;
|
return;
|
||||||
|
|
@ -1031,5 +1029,6 @@ private void customRTB_KeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
caretPos = customRTB.SelectionStart;
|
caretPos = customRTB.SelectionStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue