private void encryptButton_Click(object sender, EventArgs e) { if (currentMode == Mode.Image && image != null) { Bitmap encrypted; if (random.Checked || randomM2.Checked) { encrypted = Steganography.InsertEncryptedTextToImage(image, textBox.Text); } else { encrypted = Steganography.InsertEncryptedTextToImageLinear(image, textBox.Text); } if (encrypted != null) { saveDialog.FileName = "*.*"; DialogResult res = saveDialog.ShowDialog(); if (res == System.Windows.Forms.DialogResult.OK) { encrypted.Save(saveDialog.FileName); OutputConsole.Write("Image saved"); } } } if (currentMode == Mode.Audio && audio != null) { byte[] file; if (random.Checked) { file = AudioSteganography.EncryptText(audio, textBox.Text); } else { file = AudioSteganography.EncryptTextLinear(audio, textBox.Text); } if (file != null) { DialogResult res = saveWav.ShowDialog(); if (res == System.Windows.Forms.DialogResult.OK) { File.WriteAllBytes(saveWav.FileName, file); OutputConsole.Write("Wav file saved"); } } } }
private void decryptButton_Click(object sender, EventArgs e) { if (currentMode == Mode.Image && image != null) { string text; if (random.Checked || randomM2.Checked) { text = Steganography.GetDecryptedTextFromImage(image); } else { text = Steganography.GetDecryptedTextFromImageLinear(image); } if (text != null) { textBox.Text = text; OutputConsole.Write("Text decrypted"); } else { //MessageBox.Show("This image doesn't have an encrypted text or an error occurred"); } } if (currentMode == Mode.Audio && audio != null) { string text; if (random.Checked) { text = AudioSteganography.DecryptText(audio); } else { text = AudioSteganography.DecryptTextLinear(audio); } if (text != null) { textBox.Text = text; OutputConsole.Write("Text decrypted"); } } }
private void decryptFile_Click(object sender, EventArgs e) { if (currentMode == Mode.Image && image != null) { HiddenFile f; stopwatch.Restart(); if (random.Checked) { f = Steganography.GetFileFromImage(image); } else { if (linear.Checked) { f = Steganography.GetFileFromImageLinear(image); } else { f = Steganography.GetFileFromImage2(image); } } if (f != null) { stopwatch.Stop(); OutputConsole.Write(string.Format("Process completed in {0} ms", stopwatch.ElapsedMilliseconds)); saveFileDialog.FileName = f.filename; DialogResult res = saveFileDialog.ShowDialog(); if (res == System.Windows.Forms.DialogResult.OK) { File.WriteAllBytes(saveFileDialog.FileName, f.file); OutputConsole.Write("File saved"); if (Path.GetExtension(saveFileDialog.FileName) == ".bmp" || Path.GetExtension(saveFileDialog.FileName) == ".png" || Path.GetExtension(saveFileDialog.FileName) == ".jpg") { ImgPreview p = new ImgPreview(Image.FromFile(saveFileDialog.FileName)); p.ShowDialog(); } } } else { //MessageBox.Show("This image doesn't have an encrypted text or an error occurred"); } stopwatch.Reset(); } if (currentMode == Mode.Audio && audio != null) { HiddenFile file; stopwatch.Restart(); if (random.Checked) { file = AudioSteganography.DecryptFile(audio); } else { if (linear.Checked) { file = AudioSteganography.DecryptFileLinear(audio); } else { file = AudioSteganography.DecryptFile2(audio); } } if (file != null) { stopwatch.Stop(); OutputConsole.Write(string.Format("Process completed in {0} ms", stopwatch.ElapsedMilliseconds)); saveFileDialog.FileName = file.filename; DialogResult res = saveFileDialog.ShowDialog(); if (res == System.Windows.Forms.DialogResult.OK) { File.WriteAllBytes(saveFileDialog.FileName, file.file); OutputConsole.Write("File saved"); if (Path.GetExtension(saveFileDialog.FileName) == ".bmp" || Path.GetExtension(saveFileDialog.FileName) == ".png" || Path.GetExtension(saveFileDialog.FileName) == ".jpg") { ImgPreview p = new ImgPreview(Image.FromFile(saveFileDialog.FileName)); p.ShowDialog(); } } } stopwatch.Reset(); } }
private void encryptFile_Click(object sender, EventArgs e) { if (currentMode == Mode.Image && image != null) { loadFileDialog.FileName = "*.*"; DialogResult res = loadFileDialog.ShowDialog(); if (res == System.Windows.Forms.DialogResult.OK) { file = File.ReadAllBytes(loadFileDialog.FileName); filename = loadFileDialog.SafeFileName; OutputConsole.Write("Added File to buffer"); Bitmap encrypted; stopwatch.Restart(); if (random.Checked) { encrypted = Steganography.InsertFileToImage(image, file, filename); } else { if (linear.Checked) { encrypted = Steganography.InsertFileToImageLinear(image, file, filename); } else { encrypted = Steganography.InsertFileToImage2(image, file, filename); } } if (encrypted != null) { stopwatch.Stop(); OutputConsole.Write(string.Format("Process completed in {0} ms", stopwatch.ElapsedMilliseconds)); saveDialog.FileName = "*.*"; DialogResult res2 = saveDialog.ShowDialog(); if (res2 == System.Windows.Forms.DialogResult.OK) { encrypted.Save(saveDialog.FileName); OutputConsole.Write("Image saved"); } } stopwatch.Reset(); } } if (currentMode == Mode.Audio && audio != null) { loadFileDialog.FileName = "*.*"; DialogResult res = loadFileDialog.ShowDialog(); if (res == System.Windows.Forms.DialogResult.OK) { byte[] file; stopwatch.Restart(); if (random.Checked) { file = AudioSteganography.EncryptFile(audio, File.ReadAllBytes(loadFileDialog.FileName), loadFileDialog.SafeFileName); } else { if (linear.Checked) { file = AudioSteganography.EncryptFileLinear(audio, File.ReadAllBytes(loadFileDialog.FileName), loadFileDialog.SafeFileName); } else { file = AudioSteganography.EncryptFile2(audio, File.ReadAllBytes(loadFileDialog.FileName), loadFileDialog.SafeFileName); } } if (file != null) { stopwatch.Stop(); OutputConsole.Write(string.Format("Process completed in {0} ms", stopwatch.ElapsedMilliseconds)); DialogResult res2 = saveWav.ShowDialog(); if (res2 == System.Windows.Forms.DialogResult.OK) { File.WriteAllBytes(saveWav.FileName, file); OutputConsole.Write("Wav file saved"); } } stopwatch.Reset(); } } }