mirror of
https://github.com/Crypto-Notepad/Crypto-Notepad.git
synced 2026-03-11 08:55:25 +00:00
testing
This commit is contained in:
parent
92b7d5fede
commit
f9237684f9
3 changed files with 75 additions and 54 deletions
6
Crypto Notepad/EnterKeyForm.Designer.cs
generated
6
Crypto Notepad/EnterKeyForm.Designer.cs
generated
|
|
@ -54,7 +54,7 @@ private void InitializeComponent()
|
|||
// button1
|
||||
//
|
||||
this.button1.Enabled = false;
|
||||
this.button1.Location = new System.Drawing.Point(111, 79);
|
||||
this.button1.Location = new System.Drawing.Point(116, 79);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(75, 23);
|
||||
this.button1.TabIndex = 1;
|
||||
|
|
@ -109,7 +109,7 @@ private void InitializeComponent()
|
|||
this.label1.TabIndex = 6;
|
||||
this.label1.Text = "Enter the encryption key:";
|
||||
//
|
||||
// Form2
|
||||
// EnterKeyForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
|
|
@ -119,7 +119,7 @@ private void InitializeComponent()
|
|||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "Form2";
|
||||
this.Name = "EnterKeyForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Crypto Notepad";
|
||||
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form2_FormClosed);
|
||||
|
|
|
|||
21
Crypto Notepad/MainForm.Designer.cs
generated
21
Crypto Notepad/MainForm.Designer.cs
generated
|
|
@ -62,8 +62,8 @@ public void InitializeComponent()
|
|||
this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.HelpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.documentationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.сheckForUpdatesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.сheckForUpdatesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.undoToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator();
|
||||
|
|
@ -363,6 +363,7 @@ public void InitializeComponent()
|
|||
// lockToolStripMenuItem
|
||||
//
|
||||
this.lockToolStripMenuItem.Name = "lockToolStripMenuItem";
|
||||
this.lockToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.L)));
|
||||
this.lockToolStripMenuItem.Size = new System.Drawing.Size(139, 22);
|
||||
this.lockToolStripMenuItem.Text = "Lock";
|
||||
this.lockToolStripMenuItem.Click += new System.EventHandler(this.lockToolStripMenuItem_Click);
|
||||
|
|
@ -378,8 +379,8 @@ public void InitializeComponent()
|
|||
//
|
||||
this.HelpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.documentationToolStripMenuItem,
|
||||
this.сheckForUpdatesToolStripMenuItem,
|
||||
this.aboutToolStripMenuItem});
|
||||
this.aboutToolStripMenuItem,
|
||||
this.сheckForUpdatesToolStripMenuItem});
|
||||
this.HelpToolStripMenuItem.Name = "HelpToolStripMenuItem";
|
||||
this.HelpToolStripMenuItem.Size = new System.Drawing.Size(43, 24);
|
||||
this.HelpToolStripMenuItem.Text = "Help";
|
||||
|
|
@ -392,13 +393,6 @@ public void InitializeComponent()
|
|||
this.documentationToolStripMenuItem.Text = "Documentation";
|
||||
this.documentationToolStripMenuItem.Click += new System.EventHandler(this.documentationToolStripMenuItem_Click);
|
||||
//
|
||||
// сheckForUpdatesToolStripMenuItem
|
||||
//
|
||||
this.сheckForUpdatesToolStripMenuItem.Name = "сheckForUpdatesToolStripMenuItem";
|
||||
this.сheckForUpdatesToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
|
||||
this.сheckForUpdatesToolStripMenuItem.Text = "Сheck for Updates...";
|
||||
this.сheckForUpdatesToolStripMenuItem.Click += new System.EventHandler(this.сheckForUpdatesToolStripMenuItem_Click);
|
||||
//
|
||||
// aboutToolStripMenuItem
|
||||
//
|
||||
this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
|
||||
|
|
@ -406,6 +400,13 @@ public void InitializeComponent()
|
|||
this.aboutToolStripMenuItem.Text = "About";
|
||||
this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);
|
||||
//
|
||||
// сheckForUpdatesToolStripMenuItem
|
||||
//
|
||||
this.сheckForUpdatesToolStripMenuItem.Name = "сheckForUpdatesToolStripMenuItem";
|
||||
this.сheckForUpdatesToolStripMenuItem.Size = new System.Drawing.Size(187, 22);
|
||||
this.сheckForUpdatesToolStripMenuItem.Text = "Сheck for Updates...";
|
||||
this.сheckForUpdatesToolStripMenuItem.Click += new System.EventHandler(this.сheckForUpdatesToolStripMenuItem_Click);
|
||||
//
|
||||
// contextMenuStrip1
|
||||
//
|
||||
this.contextMenuStrip1.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using File = System.IO.File;
|
||||
|
||||
|
|
@ -51,7 +52,7 @@ void DecryptAES()
|
|||
string opnfile = File.ReadAllText(OpenFile.FileName);
|
||||
string NameWithotPath = Path.GetFileName(OpenFile.FileName);
|
||||
|
||||
string de = AES.Decrypt(opnfile, TypedPassword.Value, ps.TheSalt, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
|
||||
string de = AES.Decrypt(opnfile, TypedPassword.Value, null, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
|
||||
customRTB.Text = de;
|
||||
|
||||
this.Text = appName + NameWithotPath;
|
||||
|
|
@ -141,7 +142,7 @@ private void openAsotiations()
|
|||
}
|
||||
PublicVar.okPressed = false;
|
||||
|
||||
string de = AES.Decrypt(opnfile, TypedPassword.Value, ps.TheSalt, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
|
||||
string de = AES.Decrypt(opnfile, TypedPassword.Value, null, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
|
||||
customRTB.Text = de;
|
||||
|
||||
this.Text = appName + NameWithotPath;
|
||||
|
|
@ -196,7 +197,7 @@ private void sendTo()
|
|||
return;
|
||||
}
|
||||
PublicVar.okPressed = false;
|
||||
string de = AES.Decrypt(opnfile, TypedPassword.Value, ps.TheSalt, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
|
||||
string de = AES.Decrypt(opnfile, TypedPassword.Value, null, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
|
||||
customRTB.Text = de;
|
||||
|
||||
this.Text = appName + NameWithotPath;
|
||||
|
|
@ -294,15 +295,7 @@ private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
|
|||
filePath = SaveFile.FileName;
|
||||
string noenc = customRTB.Text;
|
||||
string en;
|
||||
if (PublicVar.randomizeSalts)
|
||||
{
|
||||
en = AES.Encrypt(customRTB.Text, TypedPassword.Value, null, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
|
||||
}
|
||||
else
|
||||
{
|
||||
en = AES.Encrypt(customRTB.Text, TypedPassword.Value, ps.TheSalt, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
|
||||
}
|
||||
|
||||
en = AES.Encrypt(customRTB.Text, TypedPassword.Value, null, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
|
||||
customRTB.Text = en;
|
||||
StreamWriter sw = new StreamWriter(filePath);
|
||||
int i = customRTB.Lines.Count();
|
||||
|
|
@ -560,35 +553,25 @@ private void clearToolStripMenuItem_Click(object sender, EventArgs e)
|
|||
|
||||
private void saveToolStripMenuItem1_Click_1(object sender, EventArgs e)
|
||||
{
|
||||
string noname = "Unnamed.cnp";
|
||||
string NameWithotPath = Path.GetFileName(OpenFile.FileName);
|
||||
int saveCaret = customRTB.SelectionStart;
|
||||
|
||||
if (PublicVar.encryptionKey.Get() == null)
|
||||
{
|
||||
SaveFile.FileName = noname;
|
||||
saveAsToolStripMenuItem_Click(this, new EventArgs());
|
||||
|
||||
SaveFile.FileName = "Unnamed.cnp";
|
||||
saveAsToolStripMenuItem_Click(sender, e);
|
||||
if (PublicVar.okPressed == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PublicVar.okPressed = false;
|
||||
}
|
||||
|
||||
string noenc = customRTB.Text;
|
||||
string en;
|
||||
if (PublicVar.randomizeSalts)
|
||||
{
|
||||
en = AES.Encrypt(customRTB.Text, PublicVar.encryptionKey.Get(), null, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
|
||||
}
|
||||
else
|
||||
{
|
||||
en = AES.Encrypt(customRTB.Text, PublicVar.encryptionKey.Get(), ps.TheSalt, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
|
||||
}
|
||||
|
||||
|
||||
en = AES.Encrypt(customRTB.Text, PublicVar.encryptionKey.Get(), null, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
|
||||
customRTB.Text = en;
|
||||
|
||||
StreamWriter sw = new StreamWriter(filePath);
|
||||
int i = customRTB.Lines.Count();
|
||||
int j = 0;
|
||||
|
|
@ -599,11 +582,12 @@ private void saveToolStripMenuItem1_Click_1(object sender, EventArgs e)
|
|||
sw.WriteLine(customRTB.Lines.GetValue(j).ToString());
|
||||
j = j + 1;
|
||||
}
|
||||
|
||||
sw.Close();
|
||||
|
||||
customRTB.Text = noenc;
|
||||
customRTB.Select(Convert.ToInt32(saveCaret), 0);
|
||||
PublicVar.keyChanged = false;
|
||||
//CheckFileSavedCorrectly(sender, e);
|
||||
}
|
||||
|
||||
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
|
|
@ -845,7 +829,7 @@ private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
|
|||
sf.ShowDialog();
|
||||
}
|
||||
|
||||
private void MainWindow_Activated(object sender, EventArgs e)
|
||||
private async void MainWindow_Activated(object sender, EventArgs e)
|
||||
{
|
||||
if (PublicVar.settingsChanged == true)
|
||||
{
|
||||
|
|
@ -949,11 +933,21 @@ private void findToolStripMenuItem2_Click(object sender, EventArgs e)
|
|||
|
||||
private void documentationToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Process.Start("https://github.com/Sigmanor/Crypto-Notepad/wiki/Documentation");
|
||||
//Process.Start("https://github.com/Sigmanor/Crypto-Notepad/wiki/Documentation");
|
||||
//MessageBox.Show("currentFilename: " + currentFilename);
|
||||
//MessageBox.Show("encryptionKey: " + PublicVar.encryptionKey.Get());
|
||||
//MessageBox.Show("TypedPassword: " + TypedPassword.Value);
|
||||
//MessageBox.Show("filePath: " + filePath);
|
||||
|
||||
int i = 1;
|
||||
while (i != 100)
|
||||
{
|
||||
i++;
|
||||
Text = i.ToString();
|
||||
saveToolStripMenuItem1_Click_1(sender, e);
|
||||
CheckFileSavedCorrectly(sender, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ToolsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||
|
|
@ -1158,7 +1152,8 @@ void AutoLock(bool minimize)
|
|||
PublicVar.encryptionKey.Set(null);
|
||||
customRTB.Clear();
|
||||
this.Text = appName.Remove(14);
|
||||
OpenFile.FileName = "";
|
||||
currentFilename = "";
|
||||
filePath = "";
|
||||
this.Show();
|
||||
return;
|
||||
}
|
||||
|
|
@ -1166,15 +1161,13 @@ void AutoLock(bool minimize)
|
|||
|
||||
try
|
||||
{
|
||||
OpenFile.FileName = filePath;
|
||||
string opnfile = File.ReadAllText(OpenFile.FileName);
|
||||
string NameWithotPath = Path.GetFileName(OpenFile.FileName);
|
||||
string de = AES.Decrypt(opnfile, TypedPassword.Value, ps.TheSalt, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
|
||||
|
||||
this.Text = appName + NameWithotPath;
|
||||
filePath = OpenFile.FileName;
|
||||
|
||||
customRTB.Clear();
|
||||
string opnfile = File.ReadAllText(filePath);
|
||||
string de = AES.Decrypt(opnfile, TypedPassword.Value, null, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
|
||||
customRTB.Text = de;
|
||||
this.Text = appName + currentFilename;
|
||||
string cc2 = customRTB.Text.Length.ToString(CultureInfo.InvariantCulture);
|
||||
customRTB.Select(Convert.ToInt32(cc2), 0);
|
||||
customRTB.SelectionStart = caretPos;
|
||||
PublicVar.encryptionKey.Set(TypedPassword.Value);
|
||||
TypedPassword.Value = null;
|
||||
|
|
@ -1195,7 +1188,8 @@ void AutoLock(bool minimize)
|
|||
PublicVar.encryptionKey.Set(null);
|
||||
customRTB.Clear();
|
||||
this.Text = appName.Remove(14);
|
||||
OpenFile.FileName = "";
|
||||
filePath = "";
|
||||
currentFilename = "";
|
||||
this.Show();
|
||||
return;
|
||||
}
|
||||
|
|
@ -1210,10 +1204,17 @@ protected override void WndProc(ref Message m)
|
|||
|
||||
if (m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_MINIMIZE && ps.AutoLock == true && PublicVar.encryptionKey.Get() != null)
|
||||
{
|
||||
if (ps.AutoSave)
|
||||
{
|
||||
saveToolStripMenuItem1_Click_1(this, new EventArgs());
|
||||
}
|
||||
else
|
||||
{
|
||||
saveConfirm(false);
|
||||
}
|
||||
AutoLock(true);
|
||||
return;
|
||||
}
|
||||
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
|
||||
|
|
@ -1378,5 +1379,24 @@ private void customRTB_KeyUp(object sender, KeyEventArgs e)
|
|||
shiftPresed = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckFileSavedCorrectly(object sender, EventArgs e)
|
||||
{
|
||||
string de = "";
|
||||
try
|
||||
{
|
||||
string opnfile = File.ReadAllText(OpenFile.FileName);
|
||||
de = AES.Decrypt(opnfile, PublicVar.encryptionKey.Get(), null, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
|
||||
customRTB.Text = de;
|
||||
string cc2 = customRTB.Text.Length.ToString(CultureInfo.InvariantCulture);
|
||||
customRTB.Select(Convert.ToInt32(cc2), 0);
|
||||
}
|
||||
catch (CryptographicException)
|
||||
{
|
||||
MessageBox.Show("Gotcha!");
|
||||
saveToolStripMenuItem1_Click_1(sender, e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue