private void ExtractAllButton_Click(object sender, EventArgs e) { string decoded; string folder = UrlTextBox.Text; Bitmap temp; // directory does not exist if (Directory.Exists(folder) == false) { return; } DecryptAllTextBox.Text = string.Empty; // get the files in the folder var files = Directory.GetFiles(folder); foreach (var f in files) { // if it is an image file if (ImageExtensions.Contains(Path.GetExtension(f).ToUpperInvariant())) { // get the image file and extract the data temp = ImageToBMP(f); decoded = Steg.Extract(temp); // hidden text was found, so display if (decoded != string.Empty) { DecryptAllTextBox.Text += f.Substring(f.LastIndexOf("\\") + 1) + Environment.NewLine + decoded + Environment.NewLine + Environment.NewLine; } } } }
// user decodes data private void DecodeButton_Click(object sender, EventArgs e) { // exit if there is no bmp file if (ValidDetails() == false) { return; } string decoded = Steg.Extract(bmp); // decrypt for the user if (PasswordCheckBox.Checked == true) { try { decoded = StringCipher.Decrypt(decoded, PasswordTextBox.Text); } catch (System.Security.Cryptography.CryptographicException) { MessageBox.Show( "Image or password is incorrect.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } catch (System.FormatException) { MessageBox.Show( "Image was not large enough to hide all text, and therefore the text cannot be extracted.", "Image Size Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } decoded = "Decoded text:" + Environment.NewLine + decoded; WordsTextBox.Text = decoded; }