Merge pull request #10 from h5p9sl/master

Backwards compatibility & More security
This commit is contained in:
Alexander 2018-12-06 12:30:26 +02:00 committed by GitHub
commit 7ba9b6aca0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 225 additions and 176 deletions

View file

@ -2,6 +2,8 @@
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Windows.Forms;
using System.Collections.Generic;
namespace Crypto_Notepad
{
@ -13,109 +15,118 @@ class AESMetadata
/// <summary>
/// Offset to actual AES data; size of metadata
/// </summary>
private int _offsetToData;
public int offsetToData
{
get
{
return this._offsetToData;
}
}
private byte[] _initialVector;
public byte[] initialVector
{
get
{
return this._initialVector;
}
}
private byte[] _salt;
public byte[] salt
{
get
{
return this._salt;
}
}
public int OffsetToData { get; private set; }
public byte[] InitialVector { get; private set; }
public byte[] Salt { get; private set; }
public AESMetadata()
{
this._initialVector = new byte[16];
this._salt = null;
this.InitialVector = new byte[16];
this.Salt = null;
}
public void DeleteMetadataFromBuffer(ref byte[] rawData)
{
// Possibly unsafe
byte[] buffer = new byte[rawData.Length - this.offsetToData];
System.Buffer.BlockCopy(rawData, this.offsetToData, buffer, 0, rawData.Length - this.offsetToData);
byte[] buffer = new byte[rawData.Length - this.OffsetToData];
System.Buffer.BlockCopy(rawData, this.OffsetToData, buffer, 0, rawData.Length - this.OffsetToData);
rawData = buffer;
}
public void GetMetadata(byte[] rawData)
private bool ReadData(byte[] rawData, int offset, ref byte[] dataOut)
{
int index = 0;
// Read initialVector
for (int i = 0; index < rawData.Length; index++, i++)
{
if (rawData[index] == '\0') // Null terminator
{
index++;
break;
}
this.initialVector[i] = rawData[index];
}
// This is kind of a dirty fix, but it gets the job done
// Get length of salt
int length = 0;
for (int i = index; i < rawData.Length; i++)
{
if (rawData[i] == '\0') // Null terminator
{
index++;
break;
}
length++;
}
// Copy bytes into this.salt
this._salt = new byte[length];
System.Buffer.BlockCopy(rawData, index - 1, this.salt, 0, length);
// Buffer to store bytes
List<byte> buffer = new List<byte>();
const byte nullTerminator = 0;
bool foundData = false;
this._offsetToData = this.salt.Length + 1 + this.initialVector.Length + 1;
// Push data to buffer
for (int i = offset; i < rawData.Length; i++) {
if (rawData[i] == nullTerminator) { foundData = true; break; }
else { buffer.Add(rawData[i]); }
}
if (foundData == true)
{
dataOut = buffer.ToArray();
return true;
}
return false;
}
public static void WriteMetadata(MemoryStream stream, byte[] IV, byte[] salt)
{
byte[] nullByte = { 0 };
stream.Write(IV, 0, IV.Length);
stream.Write(nullByte, 0, 1);
stream.Write(salt, 0, salt.Length);
stream.Write(nullByte, 0, 1);
}
public bool GetMetadata(byte[] rawData)
{
int offset = 0;
byte[] buffer = null;
if (!this.ReadData(rawData, 0, ref buffer)) { return false; }
this.InitialVector = buffer;
offset += buffer.Length + 1;
if (!this.ReadData(rawData, offset, ref buffer)) { return false; }
this.Salt = buffer;
offset += buffer.Length + 1;
this.OffsetToData = offset;
return true;
}
}
class AES
{
public static string Encrypt(string plainText, string password, byte[] initialVectorBytes,
string salt = "Kosher", string hashAlgorithm = "SHA1",
public static string Encrypt(string plainText, string password,
string salt = null, string hashAlgorithm = "SHA1",
int passwordIterations = 2, int keySize = 256)
{
if (string.IsNullOrEmpty(plainText))
return "";
byte[] saltValueBytes = Encoding.ASCII.GetBytes(salt);
byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainText);
byte[] plainTextBytes;
byte[] saltValueBytes;
// In case user wants a random salt or salt is null/empty for some other reason
if (string.IsNullOrEmpty(salt))
{
saltValueBytes = new byte[64]; // Nice and long
RandomNumberGenerator rng = RandomNumberGenerator.Create();
rng.GetNonZeroBytes(saltValueBytes);
rng.Dispose();
}
else
{
saltValueBytes = Encoding.ASCII.GetBytes(salt);
}
plainTextBytes = Encoding.UTF8.GetBytes(plainText);
PasswordDeriveBytes derivedPassword = new PasswordDeriveBytes
(password, saltValueBytes, hashAlgorithm, passwordIterations);
// Null password; adds *some* memory dump protection
password = null;
byte[] keyBytes = derivedPassword.GetBytes(keySize / 8);
RijndaelManaged symmetricKey = new RijndaelManaged();
symmetricKey.Mode = CipherMode.CBC;
symmetricKey.GenerateIV();
byte[] cipherTextBytes = null;
using (MemoryStream memStream = new MemoryStream())
{
byte[] nullByte = { 0 };
memStream.Write(initialVectorBytes, 0, initialVectorBytes.Length);
memStream.Write(nullByte, 0, 1);
memStream.Write(saltValueBytes, 0, saltValueBytes.Length);
memStream.Write(nullByte, 0, 1);
AESMetadata.WriteMetadata(memStream, symmetricKey.IV, saltValueBytes);
using (ICryptoTransform encryptor = symmetricKey.CreateEncryptor
(keyBytes, initialVectorBytes))
(keyBytes, symmetricKey.IV))
{
using (CryptoStream cryptoStream = new CryptoStream
(memStream, encryptor, CryptoStreamMode.Write))
@ -133,13 +144,13 @@ public static string Encrypt(string plainText, string password, byte[] initialVe
return Convert.ToBase64String(cipherTextBytes);
}
public static string Decrypt(string cipherText, string password,
public static string Decrypt(string cipherText, string password, string salt = "Kosher",
string hashAlgorithm = "SHA1",
int passwordIterations = 2,
int keySize = 256)
{
if (string.IsNullOrEmpty(cipherText))
return "";
return null;
byte[] initialVectorBytes;
byte[] saltValueBytes;
@ -147,10 +158,27 @@ public static string Decrypt(string cipherText, string password,
// Extract metadata from file
AESMetadata metadata = new AESMetadata();
metadata.GetMetadata(cipherTextBytes);
saltValueBytes = metadata.salt;
initialVectorBytes = metadata.initialVector;
metadata.DeleteMetadataFromBuffer(ref cipherTextBytes);
if (!metadata.GetMetadata(cipherTextBytes))
{
// 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);
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
{
saltValueBytes = metadata.Salt;
initialVectorBytes = metadata.InitialVector;
metadata.DeleteMetadataFromBuffer(ref cipherTextBytes);
}
PasswordDeriveBytes derivedPassword = new PasswordDeriveBytes
(password, saltValueBytes, hashAlgorithm, passwordIterations);

View file

@ -14,9 +14,9 @@ public ChangeKeyForm()
private async void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == publicVar.encryptionKey & textBox1.Text != textBox2.Text)
if (textBox1.Text == publicVar.encryptionKey.Get() & textBox1.Text != textBox2.Text)
{
publicVar.encryptionKey = textBox2.Text;
publicVar.encryptionKey.Set(textBox2.Text);
publicVar.keyChanged = true;
textBox1.Text = "";
textBox2.Text = "";
@ -28,7 +28,7 @@ private async void button1_Click(object sender, EventArgs e)
return;
}
if (textBox1.Text != publicVar.encryptionKey)
if (textBox1.Text != publicVar.encryptionKey.Get())
{
SystemSounds.Beep.Play();
statusLabel.Text = "Invalid old key!";

View file

@ -105,6 +105,7 @@
<Compile Include="CustomRichTextBox.Designer.cs">
<DependentUpon>CustomRichTextBox.cs</DependentUpon>
</Compile>
<Compile Include="EncryptedString.cs" />
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>

View file

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography;
namespace Crypto_Notepad
{
/// <summary>
/// Stores a string encrypted in memory to defend against memory dumps
/// </summary>
class EncryptedString
{
private TripleDES des = TripleDESCryptoServiceProvider.Create();
private byte[] encryptedString = null;
public EncryptedString(string String)
{
this.des.GenerateIV();
this.des.GenerateKey();
this.Set(String);
}
public EncryptedString()
{
this.des.GenerateIV();
this.des.GenerateKey();
}
public string Get()
{
if (this.encryptedString == null) return null;
var decryptor = this.des.CreateDecryptor();
byte[] output = decryptor.TransformFinalBlock(this.encryptedString, 0, this.encryptedString.Length);
return Encoding.Default.GetString(output);
}
public void Set(string String)
{
if (String == null) { this.encryptedString = null; return; }
var encryptor = this.des.CreateEncryptor();
byte[] str = Encoding.Default.GetBytes(String);
this.encryptedString = encryptor.TransformFinalBlock(str, 0, str.Length);
}
}
}

View file

@ -88,7 +88,7 @@ void DecryptAES()
{
string opnfile = File.ReadAllText(OpenFile.FileName);
string NameWithotPath = Path.GetFileName(OpenFile.FileName);
string de = AES.Decrypt(opnfile, publicVar.encryptionKey, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
string de = AES.Decrypt(opnfile, publicVar.encryptionKey.Get(), ps.TheSalt, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
customRTB.Text = de;
this.Text = appName + NameWithotPath;
@ -165,7 +165,7 @@ private void openAsotiations()
}
publicVar.okPressed = false;
string de = AES.Decrypt(opnfile, publicVar.encryptionKey, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
string de = AES.Decrypt(opnfile, publicVar.encryptionKey.Get(), ps.TheSalt, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
customRTB.Text = de;
this.Text = appName + NameWithotPath;
@ -216,7 +216,7 @@ private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
{
int saveCaret = customRTB.SelectionStart;
string NameWithotPath = Path.GetFileName(OpenFile.FileName);
if (string.IsNullOrEmpty(publicVar.encryptionKey))
if (string.IsNullOrEmpty(publicVar.encryptionKey.Get()))
{
Form2 Form2 = new Form2();
Form2.ShowDialog();
@ -234,14 +234,16 @@ private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
filename = SaveFile.FileName;
// Generate random initialization vector
RandomNumberGenerator RandNumGen = RNGCryptoServiceProvider.Create();
byte[] RandInitVector = new byte[16];
RandNumGen.GetNonZeroBytes(RandInitVector);
string noenc = customRTB.Text;
string en = AES.Encrypt(customRTB.Text, publicVar.encryptionKey, RandInitVector, ps.TheSalt, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
RandNumGen.Dispose();
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);
}
customRTB.Text = en;
StreamWriter sw = new StreamWriter(filename);
@ -381,14 +383,16 @@ private void saveToolStripMenuItem1_Click_1(object sender, EventArgs e)
publicVar.okPressed = false;
}
// Generate random initialization vector
RandomNumberGenerator RandNumGen = RNGCryptoServiceProvider.Create();
byte[] RandInitVector = new byte[16];
RandNumGen.GetNonZeroBytes(RandInitVector);
string noenc = customRTB.Text;
string en = AES.Encrypt(customRTB.Text, publicVar.encryptionKey, RandInitVector, ps.TheSalt, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
RandNumGen.Dispose();
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);
}
customRTB.Text = en;
StreamWriter sw = new StreamWriter(filename);
@ -470,7 +474,7 @@ private void deleteFileToolStripMenuItem_Click_1(object sender, EventArgs e)
{
File.Delete(filename);
customRTB.Clear();
publicVar.encryptionKey = "";
publicVar.encryptionKey.Set(null);
pictureBox6.Enabled = false;
pictureBox7.Enabled = false;
pictureBox11.Enabled = false;
@ -687,7 +691,7 @@ private void MainWindow_Activated(object sender, EventArgs e)
customRTB.Modified = true;
}
if (publicVar.encryptionKey == "")
if (publicVar.encryptionKey.Get() == null)
{
pictureBox6.Enabled = false;
pictureBox7.Enabled = false;
@ -695,7 +699,7 @@ private void MainWindow_Activated(object sender, EventArgs e)
pictureBox13.Enabled = false;
}
if (publicVar.encryptionKey != "")
if (publicVar.encryptionKey.Get() != null)
{
pictureBox6.Enabled = true;
pictureBox7.Enabled = true;
@ -748,13 +752,13 @@ private void documentationToolStripMenuItem_Click(object sender, EventArgs e)
private void сервисToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
if (publicVar.encryptionKey == "")
if (publicVar.encryptionKey.Get() == null)
{
changeKeyToolStripMenuItem.Enabled = false;
lockToolStripMenuItem.Enabled = false;
}
if (publicVar.encryptionKey != "")
if (publicVar.encryptionKey.Get() != null)
{
changeKeyToolStripMenuItem.Enabled = true;
lockToolStripMenuItem.Enabled = true;
@ -923,7 +927,7 @@ void AutoLock(bool minimize)
{
saveToolStripMenuItem1_Click_1(this, new EventArgs());
Form2 f2 = new Form2();
publicVar.encryptionKey = "";
publicVar.encryptionKey.Set(null);
caretPos = customRTB.SelectionStart;
f2.MinimizeBox = true;
this.Hide();
@ -936,7 +940,7 @@ void AutoLock(bool minimize)
if (publicVar.okPressed == false)
{
publicVar.encryptionKey = "";
publicVar.encryptionKey.Set(null);
customRTB.Clear();
this.Text = appName.Remove(14);
OpenFile.FileName = "";
@ -950,7 +954,7 @@ void AutoLock(bool minimize)
OpenFile.FileName = filename;
string opnfile = File.ReadAllText(OpenFile.FileName);
string NameWithotPath = Path.GetFileName(OpenFile.FileName);
string de = AES.Decrypt(opnfile, publicVar.encryptionKey, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
string de = AES.Decrypt(opnfile, publicVar.encryptionKey.Get(), ps.TheSalt, ps.HashAlgorithm, ps.PasswordIterations, ps.KeySize);
this.Text = appName + NameWithotPath;
filename = OpenFile.FileName;
@ -968,7 +972,7 @@ void AutoLock(bool minimize)
}
if (dialogResult == DialogResult.Cancel)
{
publicVar.encryptionKey = "";
publicVar.encryptionKey.Set(null);
customRTB.Clear();
this.Text = appName.Remove(14);
OpenFile.FileName = "";
@ -984,7 +988,7 @@ protected override void WndProc(ref Message m)
const int WM_SYSCOMMAND = 0x112;
const int SC_MINIMIZE = 0xF020;
if (m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_MINIMIZE && ps.AutoLock == true && publicVar.encryptionKey != "")
if (m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_MINIMIZE && ps.AutoLock == true && publicVar.encryptionKey.Get() != null)
{
AutoLock(true);
return;

View file

@ -14,7 +14,7 @@ public Form2()
private void button1_Click(object sender, EventArgs e)
{
publicVar.encryptionKey = textBox1.Text;
publicVar.encryptionKey.Set(textBox1.Text);
textBox1.Focus();
textBox1.Text = "";
publicVar.okPressed = true;

View file

@ -19,7 +19,8 @@ static void Main()
static class publicVar
{
public static string encryptionKey = "";
public static EncryptedString encryptionKey = new EncryptedString();
public static bool randomizeSalts = true;
public static bool keyChanged = false;
public static bool settingsChanged = false;
public static bool okPressed = false;

View file

@ -45,8 +45,7 @@ private void InitializeComponent()
this.panel1 = new System.Windows.Forms.Panel();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.closeLabel = new System.Windows.Forms.PictureBox();
this.warningLabel = new System.Windows.Forms.Label();
this.checkBox6 = new System.Windows.Forms.CheckBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.comboBox4 = new System.Windows.Forms.ComboBox();
@ -56,17 +55,16 @@ private void InitializeComponent()
this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.checkBox5 = new System.Windows.Forms.CheckBox();
this.checkBox4 = new System.Windows.Forms.CheckBox();
this.checkBox3 = new System.Windows.Forms.CheckBox();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.button1 = new System.Windows.Forms.Button();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.checkBox5 = new System.Windows.Forms.CheckBox();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.tabPage2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.closeLabel)).BeginInit();
this.tabPage3.SuspendLayout();
this.SuspendLayout();
//
@ -86,7 +84,7 @@ private void InitializeComponent()
//
// saveSettingsButton
//
this.saveSettingsButton.Location = new System.Drawing.Point(179, 225);
this.saveSettingsButton.Location = new System.Drawing.Point(179, 239);
this.saveSettingsButton.Name = "saveSettingsButton";
this.saveSettingsButton.Size = new System.Drawing.Size(79, 23);
this.saveSettingsButton.TabIndex = 4;
@ -111,7 +109,7 @@ private void InitializeComponent()
this.tabControl1.Location = new System.Drawing.Point(2, 2);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(260, 218);
this.tabControl1.Size = new System.Drawing.Size(260, 231);
this.tabControl1.TabIndex = 4;
//
// tabPage1
@ -129,7 +127,7 @@ private void InitializeComponent()
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(252, 192);
this.tabPage1.Size = new System.Drawing.Size(252, 205);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "Fonts and Colors";
this.tabPage1.UseVisualStyleBackColor = true;
@ -226,8 +224,7 @@ private void InitializeComponent()
//
// tabPage2
//
this.tabPage2.Controls.Add(this.closeLabel);
this.tabPage2.Controls.Add(this.warningLabel);
this.tabPage2.Controls.Add(this.checkBox6);
this.tabPage2.Controls.Add(this.textBox2);
this.tabPage2.Controls.Add(this.label7);
this.tabPage2.Controls.Add(this.comboBox4);
@ -239,44 +236,28 @@ private void InitializeComponent()
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(252, 192);
this.tabPage2.Size = new System.Drawing.Size(252, 205);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "Encrypt/Decrypt";
this.tabPage2.UseVisualStyleBackColor = true;
//
// closeLabel
// checkBox6
//
this.closeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.closeLabel.BackColor = System.Drawing.Color.Gainsboro;
this.closeLabel.Cursor = System.Windows.Forms.Cursors.Hand;
this.closeLabel.Image = global::Crypto_Notepad.Properties.Resources.close_g;
this.closeLabel.Location = new System.Drawing.Point(234, 158);
this.closeLabel.Name = "closeLabel";
this.closeLabel.Size = new System.Drawing.Size(14, 14);
this.closeLabel.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.closeLabel.TabIndex = 15;
this.closeLabel.TabStop = false;
this.toolTip1.SetToolTip(this.closeLabel, "Close");
this.closeLabel.Click += new System.EventHandler(this.closeLabel_Click);
this.closeLabel.MouseEnter += new System.EventHandler(this.closeLabel_MouseEnter);
this.closeLabel.MouseLeave += new System.EventHandler(this.closeLabel_MouseLeave);
//
// warningLabel
//
this.warningLabel.BackColor = System.Drawing.Color.Gainsboro;
this.warningLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.warningLabel.ForeColor = System.Drawing.Color.Black;
this.warningLabel.Location = new System.Drawing.Point(0, 156);
this.warningLabel.Name = "warningLabel";
this.warningLabel.Size = new System.Drawing.Size(250, 36);
this.warningLabel.TabIndex = 8;
this.warningLabel.Text = "If you change settings in this tab, decrypt the previously encrypted files will n" +
"ot be possible.";
this.warningLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.checkBox6.AutoSize = true;
this.checkBox6.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
this.checkBox6.Checked = true;
this.checkBox6.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBox6.Location = new System.Drawing.Point(131, 109);
this.checkBox6.Name = "checkBox6";
this.checkBox6.Size = new System.Drawing.Size(105, 17);
this.checkBox6.TabIndex = 16;
this.checkBox6.Text = "Randomize Salts";
this.checkBox6.UseVisualStyleBackColor = true;
this.checkBox6.CheckedChanged += new System.EventHandler(this.checkBox6_CheckedChanged);
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(136, 117);
this.textBox2.Location = new System.Drawing.Point(136, 140);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 20);
this.textBox2.TabIndex = 7;
@ -284,7 +265,7 @@ private void InitializeComponent()
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(7, 120);
this.label7.Location = new System.Drawing.Point(7, 143);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(101, 13);
this.label7.TabIndex = 6;
@ -307,6 +288,7 @@ private void InitializeComponent()
this.textBox1.Location = new System.Drawing.Point(136, 83);
this.textBox1.Margin = new System.Windows.Forms.Padding(10, 3, 3, 3);
this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true;
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 4;
//
@ -360,11 +342,21 @@ private void InitializeComponent()
this.tabPage3.Location = new System.Drawing.Point(4, 22);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Padding = new System.Windows.Forms.Padding(3);
this.tabPage3.Size = new System.Drawing.Size(252, 192);
this.tabPage3.Size = new System.Drawing.Size(252, 205);
this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "Application";
this.tabPage3.UseVisualStyleBackColor = true;
//
// checkBox5
//
this.checkBox5.AutoSize = true;
this.checkBox5.Location = new System.Drawing.Point(7, 126);
this.checkBox5.Name = "checkBox5";
this.checkBox5.Size = new System.Drawing.Size(112, 17);
this.checkBox5.TabIndex = 4;
this.checkBox5.Text = "Auto-save on lock";
this.checkBox5.UseVisualStyleBackColor = true;
//
// checkBox4
//
this.checkBox4.AutoSize = true;
@ -407,7 +399,7 @@ private void InitializeComponent()
//
// button1
//
this.button1.Location = new System.Drawing.Point(6, 225);
this.button1.Location = new System.Drawing.Point(6, 239);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(98, 23);
this.button1.TabIndex = 5;
@ -415,21 +407,11 @@ private void InitializeComponent()
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// checkBox5
//
this.checkBox5.AutoSize = true;
this.checkBox5.Location = new System.Drawing.Point(7, 126);
this.checkBox5.Name = "checkBox5";
this.checkBox5.Size = new System.Drawing.Size(112, 17);
this.checkBox5.TabIndex = 4;
this.checkBox5.Text = "Auto-save on lock";
this.checkBox5.UseVisualStyleBackColor = true;
//
// SettingsForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(262, 253);
this.ClientSize = new System.Drawing.Size(262, 274);
this.Controls.Add(this.button1);
this.Controls.Add(this.tabControl1);
this.Controls.Add(this.saveSettingsButton);
@ -446,7 +428,6 @@ private void InitializeComponent()
this.tabPage1.PerformLayout();
this.tabPage2.ResumeLayout(false);
this.tabPage2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.closeLabel)).EndInit();
this.tabPage3.ResumeLayout(false);
this.tabPage3.PerformLayout();
this.ResumeLayout(false);
@ -484,9 +465,8 @@ private void InitializeComponent()
private System.Windows.Forms.Button button1;
private System.Windows.Forms.CheckBox checkBox3;
private System.Windows.Forms.CheckBox checkBox4;
private System.Windows.Forms.Label warningLabel;
private System.Windows.Forms.ToolTip toolTip1;
private System.Windows.Forms.PictureBox closeLabel;
private System.Windows.Forms.CheckBox checkBox5;
private System.Windows.Forms.CheckBox checkBox6;
}
}

View file

@ -36,12 +36,6 @@ private void SettingsForm_Load(object sender, EventArgs e)
checkBox3.Checked = ps.ShowToolbar;
checkBox4.Checked = ps.AutoLock;
checkBox5.Checked = ps.AutoSave;
if (ps.WarningMsg == false)
{
warningLabel.Visible = false;
closeLabel.Visible = false;
}
}
private void saveSettingsButton_Click(object sender, EventArgs e)
@ -178,20 +172,14 @@ private void button1_Click(object sender, EventArgs e)
private void closeLabel_Click(object sender, EventArgs e)
{
warningLabel.Visible = false;
closeLabel.Visible = false;
ps.WarningMsg = false;
ps.Save();
}
private void closeLabel_MouseEnter(object sender, EventArgs e)
private void checkBox6_CheckedChanged(object sender, EventArgs e)
{
closeLabel.Image = Properties.Resources.close_b;
}
private void closeLabel_MouseLeave(object sender, EventArgs e)
{
closeLabel.Image = Properties.Resources.close_g;
publicVar.randomizeSalts = this.checkBox6.Checked;
this.textBox1.ReadOnly = this.checkBox6.Checked;
}
}
}