Skip to content

Commit

Permalink
Added feature #11
Browse files Browse the repository at this point in the history
  • Loading branch information
Sigmanor committed Dec 9, 2018
1 parent e442c18 commit 839d4d9
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 48 deletions.
3 changes: 3 additions & 0 deletions Crypto Notepad/App.config
Expand Up @@ -72,6 +72,9 @@
<setting name="AutoSave" serializeAs="String">
<value>True</value>
</setting>
<setting name="SendTo" serializeAs="String">
<value>False</value>
</setting>
</Crypto_Notepad.Properties.Settings>
<EncryptPad.Properties.Settings>
<setting name="TopPosition" serializeAs="String">
Expand Down
58 changes: 36 additions & 22 deletions Crypto Notepad/Form1.cs
Expand Up @@ -119,38 +119,52 @@ private void openAsotiations()
{
Form2 Form2 = new Form2();
Form2.StartPosition = FormStartPosition.CenterScreen;
string fileExtension = Path.GetExtension(args[1]);

try
if (fileExtension == ".cnp")
{
string NameWithotPath = Path.GetFileName(args[1]);
string opnfile = File.ReadAllText(args[1]);

Form2.ShowDialog();
if (publicVar.okPressed == false)
try
{
OpenFile.FileName = "";
return;
}
publicVar.okPressed = false;
string NameWithotPath = Path.GetFileName(args[1]);
string opnfile = File.ReadAllText(args[1]);

string de = AES.Decrypt(opnfile, publicVar.encryptionKey.Get(), ps.TheSalt, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
customRTB.Text = de;
Form2.ShowDialog();
if (publicVar.okPressed == false)
{
OpenFile.FileName = "";
return;
}
publicVar.okPressed = false;

this.Text = appName + NameWithotPath;
string de = AES.Decrypt(opnfile, publicVar.encryptionKey.Get(), ps.TheSalt, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
customRTB.Text = de;

filename = args[1];
string cc = customRTB.Text.Length.ToString(CultureInfo.InvariantCulture);
customRTB.Select(Convert.ToInt32(cc), 0);
}
this.Text = appName + NameWithotPath;

catch
{
DialogResult dialogResult = MessageBox.Show("Invalid key!", "Crypto Notepad", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
if (dialogResult == DialogResult.Retry)
filename = args[1];
string cc = customRTB.Text.Length.ToString(CultureInfo.InvariantCulture);
customRTB.Select(Convert.ToInt32(cc), 0);
}
catch (CryptographicException)
{
openAsotiations();
DialogResult dialogResult = MessageBox.Show("Invalid key!", "Crypto Notepad", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
if (dialogResult == DialogResult.Retry)
{
openAsotiations();
}
}

}
else
{
string opnfile = File.ReadAllText(args[1]);
string NameWithotPath = Path.GetFileName(args[1]);
customRTB.Text = opnfile;
this.Text = appName + NameWithotPath;
string cc2 = customRTB.Text.Length.ToString(CultureInfo.InvariantCulture);
customRTB.Select(Convert.ToInt32(cc2), 0);
}

currentFilename = Path.GetFileName(OpenFile.FileName);
}

Expand Down
14 changes: 14 additions & 0 deletions Crypto Notepad/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Crypto Notepad/Properties/Settings.settings
Expand Up @@ -62,8 +62,11 @@
<Setting Name="WindowState" Provider="PortableSettingsProvider" Type="System.Windows.Forms.FormWindowState" Scope="User">
<Value Profile="(Default)">Normal</Value>
</Setting>
<Setting Name="AutoSave" Type="System.Boolean" Scope="User">
<Setting Name="AutoSave" Provider="PortableSettingsProvider" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="SendTo" Provider="PortableSettingsProvider" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
63 changes: 38 additions & 25 deletions Crypto Notepad/SettingsForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Crypto Notepad/SettingsForm.cs
Expand Up @@ -35,6 +35,7 @@ private void SettingsForm_Load(object sender, EventArgs e)
checkBox3.Checked = ps.ShowToolbar;
checkBox4.Checked = ps.AutoLock;
checkBox5.Checked = ps.AutoSave;
checkBox6.Checked = ps.SendTo;

if (ps.TheSalt != "")
{
Expand Down Expand Up @@ -77,6 +78,7 @@ private void SetSettings(string value)
ps.AutoCheckUpdate = checkBox2.Checked;
ps.AutoLock = checkBox4.Checked;
ps.AutoSave = checkBox5.Checked;
ps.SendTo = checkBox6.Checked;
ps.Save();
publicVar.settingsChanged = true;

Expand All @@ -95,6 +97,7 @@ private void SetSettings(string value)
checkBox3.Checked = true;
checkBox4.Checked = false;
checkBox5.Checked = true;
checkBox6.Checked = false;
}
}

Expand Down

0 comments on commit 839d4d9

Please sign in to comment.