private void btnFileSave1_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(tbPath.Text)) { WarningNotice.InputString(); return; } if (!File.Exists(tbPath.Text)) { WarningNotice.NotFound(); return; } if (tbIV.Text.Length != 8) { WarningNotice.IVLength(8); return; } if (DialogResult.OK == sfdFile.ShowDialog()) { FileInfo file = new FileInfo(tbPath.Text); FileInfo result = new FileInfo(sfdFile.FileName); fileSize = file.Length; Task.Factory.StartNew(() => { ControlEnable(this.Controls, false); TripleDESEncryption.Encrypt(file, result, tbPassword.Text, tbIV.Text); this.Invoke(new Action(() => WarningNotice.Save())); ControlEnable(this.Controls, true); }); } sfdFile.FileName = ""; }
private void btnEncrypt_Click(object sender, EventArgs e) { if (tbPassword.Text.Length != 16) { WarningNotice.KeyLength(16); return; } tbToText.Text = SEEDEncryption.Encrypt(tbFromText.Text, tbPassword.Text); }
private void btnEncrypt_Click(object sender, EventArgs e) { if (tbIV.Text.Length != 8) { WarningNotice.IVLength(8); return; } tbToText.Text = TripleDESEncryption.Encrypt(tbFromText.Text, tbPassword.Text, tbIV.Text); }
private void btnDecrypt_Click(object sender, EventArgs e) { try { tbToText.Text = RSAEncryption.RSADecrypt(tbFromText.Text, tbKey.Text); } catch (Exception) { WarningNotice.WrongKey(); } }
private void btnEncrypt_Click(object sender, EventArgs e) { if (pbImage.Image == null) { WarningNotice.NoImage(); return; } if (tbPassword.Text.Length != 16 && tbPassword.Text.Length != 24 && tbPassword.Text.Length != 32) { WarningNotice.KeyLength(16, 24, 32); return; } if (tbIV.Text.Length != 16) { WarningNotice.IVLength(16); return; } Bitmap bitmap = (Bitmap)pbImage.Image; Bitmap result; if (sfdFile.ShowDialog() == DialogResult.OK) { string fileName = sfdFile.FileName; Task.Factory.StartNew(() => { try { string hiddenText = AESEncryption.Encrypt(tbFromText.Text, tbPassword.Text, tbIV.Text); ControlEnable(this.Controls, false); fileSize = bitmap.Height; result = SteganographyConvert.Encrypt(hiddenText, (Bitmap)bitmap.Clone()); switch (sfdFile.FilterIndex) { case 0: result.Save(fileName, ImageFormat.Png); break; case 1: result.Save(fileName, ImageFormat.Bmp); break; case 2: result.Save(fileName, ImageFormat.Jpeg); break; } this.Invoke(new Action(() => WarningNotice.Save())); } catch (SteganographySizeException ex) { this.Invoke(new Action(() => WarningNotice.CantConvertImage())); } finally { ControlEnable(this.Controls, true); } }); } sfdFile.FileName = ""; }
private void btnEncrypt_Click(object sender, EventArgs e) { if (tbPassword.Text.Length != 16 && tbPassword.Text.Length != 24 && tbPassword.Text.Length != 32) { WarningNotice.KeyLength(16, 24, 32); return; } ARIAEncryption aria = new ARIAEncryption(Encoding.UTF8.GetBytes(tbPassword.Text)); tbToText.Text = aria.EncryptString(tbFromText.Text); }
private void btnEncrypt_Click(object sender, EventArgs e) { if (tbPassword.Text.Length != 16 && tbPassword.Text.Length != 24 && tbPassword.Text.Length != 32) { WarningNotice.KeyLength(16, 24, 32); return; } if (tbIV.Text.Length != 16) { WarningNotice.IVLength(16); return; } tbToText.Text = AESEncryption.Encrypt(tbFromText.Text, tbPassword.Text, tbIV.Text); }
private void btnFileSave2_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(tbPath.Text)) { WarningNotice.InputString(); return; } if (!File.Exists(tbPath.Text)) { WarningNotice.NotFound(); return; } if (tbPassword.Text.Length != 16 && tbPassword.Text.Length != 24 && tbPassword.Text.Length != 32) { WarningNotice.KeyLength(16, 24, 32); return; } if (tbIV.Text.Length != 16) { WarningNotice.IVLength(16); return; } if (DialogResult.OK == sfdFile.ShowDialog()) { FileInfo file = new FileInfo(tbPath.Text); FileInfo result = new FileInfo(sfdFile.FileName); fileSize = file.Length; Task.Factory.StartNew(() => { try { ControlEnable(this.Controls, false); AESEncryption.Decrypt(file, result, tbPassword.Text, tbIV.Text); this.Invoke(new Action(() => WarningNotice.Save())); } catch (Exception) { WarningNotice.WrongKey(); } finally { ControlEnable(this.Controls, true); } }); } sfdFile.FileName = ""; }
private void btnDecrypt_Click(object sender, EventArgs e) { if (tbIV.Text.Length != 8) { WarningNotice.IVLength(8); return; } try { tbToText.Text = TripleDESEncryption.Decrypt(tbFromText.Text, tbPassword.Text, tbIV.Text); } catch (Exception) { WarningNotice.WrongKey(); } }
private void btnDecrypt_Click(object sender, EventArgs e) { if (tbPassword.Text.Length != 16) { WarningNotice.KeyLength(16); return; } try { tbToText.Text = SEEDEncryption.Decrypt(tbFromText.Text, tbPassword.Text); } catch (Exception) { WarningNotice.WrongKey(); } }
private void btnVerify_Click(object sender, EventArgs e) { try { if (ECDSAEncryption.Verify(tbBefore.Text, tbAfter.Text, tbKey.Text)) { StatusPictureBox.Image = global::암호화_복호화_프로그램.Properties.Resources.ok; } else { StatusPictureBox.Image = global::암호화_복호화_프로그램.Properties.Resources.error; } } catch (Exception) { WarningNotice.WrongKey(); } }
private void btnEncrypt_Click(object sender, EventArgs e) { if (tbIV.Text.Length != 8) { WarningNotice.IVLength(8); return; } if (!(tbPassword.Text.Length > 0 && tbPassword.Text.Length <= 56)) { WarningNotice.KeyLength(1, 56); return; } BlowFishEncryption blow = new BlowFishEncryption(Encoding.UTF8.GetBytes(tbPassword.Text)); blow.IV = Encoding.UTF8.GetBytes(tbIV.Text); byte[] result = blow.Encrypt_CBC(Encoding.UTF8.GetBytes(tbFromText.Text)); tbToText.Text = Convert.ToBase64String(result); }
private void RandomCodeButton1_Click(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(tbLength.Text) || String.IsNullOrWhiteSpace(tbInclude.Text)) { WarningNotice.Null(); return; } if (!int.TryParse(tbLength.Text, out _)) { if (long.TryParse(tbLength.Text, out _)) { WarningNotice.IsLongType(); return; } WarningNotice.NotNumber(); return; } tbRandomCodeResult.Text = RandomCode.GetRandomString(int.Parse(tbLength.Text), tbInclude.Text); }
private void btnCheckResult_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(tbPath.Text)) { WarningNotice.InputString(); return; } if (!File.Exists(tbPath.Text)) { WarningNotice.NotFound(); return; } FileInfo file = new FileInfo(tbPath.Text); if (cbHMACMode.Checked) { Task.Factory.StartNew(() => { ControlEnable(this.Controls, false); Task <string> task = Task.Factory.StartNew <string>(new Func <string>(() => HMACRIPEMD160Encryption.Encrypt(file, tbHMACPassword.Text))); task.Wait(); this.Invoke(new Action(() => tbResult.Text = task.Result)); this.Invoke(new Action(() => WarningNotice.Completed())); ControlEnable(this.Controls, true); }); } else { Task.Factory.StartNew(() => { ControlEnable(this.Controls, false); Task <string> task = Task.Factory.StartNew <string>(new Func <string>(() => RIPEMD160Encryption.Encrypt(file))); task.Wait(); this.Invoke(new Action(() => tbResult.Text = task.Result)); this.Invoke(new Action(() => WarningNotice.Completed())); ControlEnable(this.Controls, true); }); } }
private void btnDecrypt_Click(object sender, EventArgs e) { if (pbImage.Image == null) { WarningNotice.NoImage(); return; } if (tbPassword.Text.Length != 16 && tbPassword.Text.Length != 24 && tbPassword.Text.Length != 32) { WarningNotice.KeyLength(16, 24, 32); return; } if (tbIV.Text.Length != 16) { WarningNotice.IVLength(16); return; } Bitmap bitmap = (Bitmap)pbImage.Image; Task.Factory.StartNew(() => { ControlEnable(this.Controls, false); fileSize = bitmap.Height; string hiddenText = SteganographyConvert.Decrypt(bitmap); this.Invoke(new Action(() => { try { tbToText.Text = AESEncryption.Decrypt(hiddenText, tbPassword.Text, tbIV.Text); WarningNotice.Completed(); } catch (Exception) { this.Invoke(new Action(() => WarningNotice.WrongKey())); } })); ControlEnable(this.Controls, true); }); }
private void RandomNumberButton_Click(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(tbMinimum.Text) || String.IsNullOrWhiteSpace(tbMaximum.Text)) { WarningNotice.Null(); return; } if (!(int.TryParse(tbMinimum.Text, out _) && int.TryParse(tbMaximum.Text, out _))) { if (long.TryParse(tbMinimum.Text, out _) || long.TryParse(tbMaximum.Text, out _)) { WarningNotice.IsLongType(); return; } WarningNotice.NotNumber(); return; } if (int.Parse(tbMinimum.Text) > int.Parse(tbMaximum.Text)) { WarningNotice.MinAndMaxNumber(); } tbRandomNumberResult.Text = RandomCode.GetRandomNumber(int.Parse(tbMinimum.Text), int.Parse(tbMaximum.Text)).ToString(); }
private void btnCheckResult_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(tbPath.Text)) { WarningNotice.InputString(); return; } if (!File.Exists(tbPath.Text)) { WarningNotice.NotFound(); return; } FileInfo file = new FileInfo(tbPath.Text); Task.Factory.StartNew(() => { switch (gbSHAMode.Controls.OfType <RadioButton>().FirstOrDefault(rb => rb.Checked)) { case RadioButton rb1 when rb1.Name == rdbtnSHA1.Name: if (cbHMACMode.Checked) { ControlEnable(this.Controls, false); Task <string> task = Task.Factory.StartNew <string>(new Func <string>(() => HMACSHA1Encryption.Encrypt(file, tbHMACPassword.Text))); task.Wait(); this.Invoke(new Action(() => tbResult.Text = task.Result)); this.Invoke(new Action(() => WarningNotice.Completed())); ControlEnable(this.Controls, true); } else { ControlEnable(this.Controls, false); Task <string> task = Task.Factory.StartNew <string>(new Func <string>(() => SHA1Encryption.Encrypt(file))); task.Wait(); this.Invoke(new Action(() => tbResult.Text = task.Result)); this.Invoke(new Action(() => WarningNotice.Completed())); ControlEnable(this.Controls, true); } break; case RadioButton rb2 when rb2.Name == rdbtnSHA256.Name: if (cbHMACMode.Checked) { ControlEnable(this.Controls, false); Task <string> task = Task.Factory.StartNew <string>(new Func <string>(() => HMACSHA256Encryption.Encrypt(file, tbHMACPassword.Text))); task.Wait(); this.Invoke(new Action(() => tbResult.Text = task.Result)); this.Invoke(new Action(() => WarningNotice.Completed())); ControlEnable(this.Controls, true); } else { ControlEnable(this.Controls, false); Task <string> task = Task.Factory.StartNew <string>(new Func <string>(() => SHA256Encryption.Encrypt(file))); task.Wait(); this.Invoke(new Action(() => tbResult.Text = task.Result)); this.Invoke(new Action(() => WarningNotice.Completed())); ControlEnable(this.Controls, true); } break; case RadioButton rb3 when rb3.Name == rdbtnSHA384.Name: if (cbHMACMode.Checked) { ControlEnable(this.Controls, false); Task <string> task = Task.Factory.StartNew <string>(new Func <string>(() => HMACSHA384Encryption.Encrypt(file, tbHMACPassword.Text))); task.Wait(); this.Invoke(new Action(() => tbResult.Text = task.Result)); this.Invoke(new Action(() => WarningNotice.Completed())); ControlEnable(this.Controls, true); } else { ControlEnable(this.Controls, false); Task <string> task = Task.Factory.StartNew <string>(new Func <string>(() => SHA384Encryption.Encrypt(file))); task.Wait(); this.Invoke(new Action(() => tbResult.Text = task.Result)); this.Invoke(new Action(() => WarningNotice.Completed())); ControlEnable(this.Controls, true); } break; case RadioButton rb4 when rb4.Name == rdbtnSHA512.Name: if (cbHMACMode.Checked) { ControlEnable(this.Controls, false); Task <string> task = Task.Factory.StartNew <string>(new Func <string>(() => HMACSHA512Encryption.Encrypt(file, tbHMACPassword.Text))); task.Wait(); this.Invoke(new Action(() => tbResult.Text = task.Result)); this.Invoke(new Action(() => WarningNotice.Completed())); ControlEnable(this.Controls, true); } else { ControlEnable(this.Controls, false); Task <string> task = Task.Factory.StartNew <string>(new Func <string>(() => SHA512Encryption.Encrypt(file))); task.Wait(); this.Invoke(new Action(() => tbResult.Text = task.Result)); this.Invoke(new Action(() => WarningNotice.Completed())); ControlEnable(this.Controls, true); } break; } }); }