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 (tbIV.Text.Length != 8) { WarningNotice.IVLength(8); return; } tbToText.Text = TripleDESEncryption.Encrypt(tbFromText.Text, tbPassword.Text, tbIV.Text); }
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; } 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 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 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); }); }