void Decrypt() { try { if (txtSource.Text == null || txtSource.Text.Trim() == string.Empty) throw new Exception("Please specify file(s) to decrypt."); if (string.IsNullOrEmpty(txtPassword.Text)) throw new Exception("Please specify the password for the encryption."); //get source files //for each source file //get the embedded file //if (delete source file), delete source file //save embedded file (ask user to choose file name) string[] sourceFiles = GetSourceFiles(); if (sourceFiles.Length == 0) throw new Exception("Source file(s) could not be found."); for (int index = 0; index < sourceFiles.Length; ++index) { byte[] embeddedFile = Steganographer.Dec(sourceFiles[index], txtPassword.Text); if (embeddedFile == null) throw new Exception("Decryption Failed."); if (chckDeleteSource.Checked) File.Delete(sourceFiles[index]); if (saveDialog.ShowDialog() == DialogResult.OK) { FileSystemServices.WriteBytesToFile(saveDialog.FileName, embeddedFile); } } } catch (Exception ex) { MsgBox msg = new MsgBox(ex.Message, MessageType.Error, ResponseButtons.OK); msg.ShowDialog(); } }
void picMaskImage_Click(object sender, EventArgs e) { try { if (openDialog.ShowDialog() == DialogResult.OK) { picMaskImage.BackgroundImage = Image.FromFile(openDialog.FileName); maskImagePath = openDialog.FileName; } } catch (Exception ex) { MsgBox msg = new MsgBox(ex.Message, MessageType.Error, ResponseButtons.OK); msg.ShowDialog(); } }
void Encrypt() { try { if (txtSource.Text == null || txtSource.Text.Trim() == string.Empty) throw new Exception("Please specify file(s) to encrypt."); if (maskImagePath == null || maskImagePath.Trim() == string.Empty) throw new Exception("Please click the large picture box to select the picture to use for masking."); if (string.IsNullOrEmpty(txtPassword.Text)) throw new Exception("Please specify the password for the encryption."); if (string.IsNullOrEmpty(txtConfirmPwd.Text)) throw new Exception("Please confirm the password for the encryption."); if (txtConfirmPwd.Text != txtPassword.Text) throw new Exception("You supplied two different passwords."); //get source files //for each source file //generate the modified image //if (delete source file), delete source file //save modified image with automatically gened name (if file with name exists, raise alarm, ask user to choose) string[] sourceFiles = GetSourceFiles(); if (sourceFiles.Length == 0) throw new Exception("Source file(s) could not be found."); for (int index = 0; index < sourceFiles.Length; ++index) { Bitmap bitmap = Steganographer.Enc(sourceFiles[index], maskImagePath, txtPassword.Text); if (bitmap == null) throw new Exception("Encryption Failed."); if (chckDeleteSource.Checked) File.Delete(sourceFiles[index]); string filePath = sourceFiles[index]; string autoGenedName = filePath.Substring(0, filePath.LastIndexOf('\\')) + "\\" + Path.GetFileNameWithoutExtension(sourceFiles[index]) + Path.GetExtension(maskImagePath); if (File.Exists(autoGenedName)) { if (saveDialog.ShowDialog() == DialogResult.OK) { bitmap.Save(saveDialog.FileName);//, ImageFormat.Png); } } else { bitmap.Save(autoGenedName); } } } catch (Exception ex) { MsgBox msg = new MsgBox(ex.Message, MessageType.Error, ResponseButtons.OK); msg.ShowDialog(); } }
public void OnAbout() { MsgBox msg = new MsgBox ( App.FullName + "\n" + "Version " + App.Version.ToString(4) + "\n" + /*(Convert.ToChar(169)).ToString() + " 2015 " + Company.Name + " Corporation\n" + "All rights reserved\n\n" +*/ App.Name + " demonstrates the possibiblity and potentials\n" + "of steganography.\n" + "I think the ability to hide info in the last bit of a byte in a\n" + "picture is interesting. Since we are altering the last bit,\n" + "you tend not to notice any difference in the image with the info.\n" + "Of course you can always notice a difference in the size of the image." /*+ "Warning:\n" + "This computer program is protected by copyright laws\n" + "and international treaties. Unauthorized reproduction\n" + "or distribution of this program, or any portion of it,\n" + "may result in severe civil and criminal penalties, and\n" + "will be prosecuted to the maximum extent under the law"*/ , "" , MessageType.Information, ResponseButtons.OK); msg.BannerImage = Properties.Resources.SplashScreen1; msg.ShowDialog(); }
void Steganographer_Feedback(object sender, FeedbackEventArgs e) { statusLabel.Text = e.FilePath; if (e.Type == FeedbackType.Progress || e.Type == FeedbackType.Begin || e.Type == FeedbackType.End) { statusLabel.Text += " " + e.Message + " "; statusProgressBar.Value = e.WorkProgress; } else { MessageType msgType = MessageType.Error; if (e.Type == FeedbackType.Information) msgType = MessageType.Information; else if (e.Type == FeedbackType.Question) msgType = MessageType.Question; else if (e.Type == FeedbackType.Warning) msgType = MessageType.Warning; MsgBox msg = new MsgBox(e.Message, msgType, ResponseButtons.OK); msg.ShowDialog(); } }
public void OnHelpTopics() { MsgBox msg = new MsgBox("For help topics, go to Start Page.", MessageType.Information, ResponseButtons.OK); msg.BannerImage = Properties.Resources.SplashScreen1; msg.ShowDialog(); }