private void generateRSA_Click(object sender, EventArgs e) { handlekeys keypair = new handlekeys(); keypair.GenerateKeyPair(); MessageBox.Show("RSA Key Pair generated and exported to ~Desktop\\Lock\\ Directory. Keep it safe!", "Heads Up!", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void DecryptBtn_Click(object sender, EventArgs e) { string cipherfile = filePathTextBox.Text; handlekeys unBox = new handlekeys(); if (endtoendCheck.Checked == true) { if (haveRSAKeyPair.Checked) { FileInfo prikeyinfo = new FileInfo(PriKeyPathTextBox.Text); if (prikeyinfo.Length > 1679) { MessageBox.Show("Private key file bigger than usual. Are you trying to trick me?", "Invalid Private Key", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (prikeyinfo.Length < 1679) { MessageBox.Show("Private key file smaller than usual. Are you trying to trick me?", "Invalid Private Key", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { unBox.AesDecrypt(cipherfile, true, PriKeyPathTextBox.Text); } } } else { unBox.AesDecrypt(cipherfile, false, null); } }
private void EncryptBtn_Click(object sender, EventArgs e) { if (radioBtnText.Checked) { //checking for text if (richTextBox1.Text.Length == 0 || richTextBox1.Text.Length > 2000) { MessageBox.Show("More than 0, less than 2000! Okay?", "Off The limits!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { File.WriteAllText(msgPath, richTextBox1.Text); string cleartext = msgPath; string ext = Path.GetExtension(cleartext); handlekeys Box = new handlekeys(); //checking for End-to-End if (endtoendCheck.Checked) { if (haveRSAKeyPair.Checked) { FileInfo pubkeyinfo = new FileInfo(PubKeyPathTextBox.Text); if (pubkeyinfo.Length > 415) { MessageBox.Show("Public key file bigger than usual. Are you trying to trick me?", "Invalid Public Key", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (pubkeyinfo.Length < 415) { MessageBox.Show("Public key file smaller than usual. Are you trying to trick me?", "Invalid Public Key", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { Box.AesEncrypt(cleartext, true, ext, PubKeyPathTextBox.Text); } } else { Box.AesEncrypt(cleartext, true, ext); } } else { Box.AesEncrypt(cleartext, false, ext); } } } else { //checking arguments if (filePathTextBox.Text.Length == 0) { MessageBox.Show("Please Specify a file!", "No file specified", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (filePathTextBox.Text.Length >= 260) { MessageBox.Show("Path is too long! Keep it short ;)", "Path too long", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { FileInfo filetoencrypt = new FileInfo(filePathTextBox.Text); if (filetoencrypt.Length > 10000000) { MessageBox.Show("File too big!", "Big File", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (filetoencrypt.Length <= 8) { MessageBox.Show("File too Small!", "Small File", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { string unEnc = filePathTextBox.Text; //Get the extention of the file string ext = Path.GetExtension(unEnc); handlekeys Box = new handlekeys(); //checking for End-to-End if (endtoendCheck.Checked == true) { if (haveRSAKeyPair.Checked) { Box.AesEncrypt(unEnc, true, ext, PubKeyPathTextBox.Text); } else { Box.AesEncrypt(unEnc, true, ext); } } else { Box.AesEncrypt(unEnc, false, ext); } } } } }