private void BtnEncrypt_Click(object sender, RoutedEventArgs e) { SaveFileDialog sdialog = new SaveFileDialog(); sdialog.Filter = "Audio files (*.wav)|*.wav"; Nullable <bool> result = sdialog.ShowDialog(); if (result == true) { try { byte[] encryptedWavFile = SteganoWav.Embed(_carrierString, _messageString); File.WriteAllBytes(sdialog.FileName, encryptedWavFile); AudioPlayer2.InitializeMedia(sdialog.FileName); AudioPlayer.InitializeMedia(_carrierString); LblEncryptedAudio.Content = sdialog.SafeFileName; MakeAudioVisible(); } catch (FileTooLargeException fileTooLargeException) { MessageBox.Show(fileTooLargeException.Message); } catch (FileNotFoundException fileNotFoundException) { MessageBox.Show(fileNotFoundException.Message); } } }
private void btnDesOutputWAV_Click(object sender, RoutedEventArgs e) { desTargetPathWAV = txtDesWAV.Text; if (!desTargetPathWAV.Equals("")) { SaveFileDialog save = new SaveFileDialog(); save.Filter = "Audio files (*.wav)|*.wav"; bool?result = save.ShowDialog(); if (result == true) { java.lang.Class clazz = typeof(Encryption); java.lang.Thread.currentThread().setContextClassLoader(clazz.getClassLoader()); String outputFile = save.FileName; try { if (Encryption.encrypt(encryptionFile, "encryptForWAV", keyFile, EncryptionMode.ENCRYPT) == java.lang.Boolean.TRUE) { String savePath = save.FileName; byte[] encryptedWavFile = SteganoWav.Embed(desTargetPathWAV, "encryptForWAV.des"); File.WriteAllBytes(savePath, encryptedWavFile); File.Delete("encryptForWAV.des"); MessageBox.Show("File successfully encrypted to audio file"); } } catch (java.io.IOException ex) { String error = ex.getMessage(); MessageBox.Show(error); } catch (FileTooLargeException fileTooLargeException) { MessageBox.Show(fileTooLargeException.Message); } } } else { MessageBox.Show("Please select a valid audio file"); } }
private void btnDesOutputWAVExtract_Click(object sender, RoutedEventArgs e) { desTargetPathWAVExtract = txtDesWAVExtract.Text; if (!desTargetPathWAVExtract.Equals("")) { SaveFileDialog save = new SaveFileDialog(); save.Filter = "All files (*.*)|*.*"; bool?result = save.ShowDialog(); if (result == true) { byte[] extracted = SteganoWav.Extract(desTargetPathWAVExtract); String extension = SteganoWav.Extention; string savePath = "extractedMessage." + extension; File.WriteAllBytes(savePath, extracted); java.lang.Class clazz = typeof(Encryption); java.lang.Thread.currentThread().setContextClassLoader(clazz.getClassLoader()); String outputFile = save.FileName; try { if (Encryption.encrypt("extractedMessage.des", outputFile, keyFile, EncryptionMode.DECRYPT) == java.lang.Boolean.TRUE) { File.Delete("extractedMessage.des"); MessageBox.Show("File successfully decrypted from audio file"); } } catch (java.io.IOException ex) { String error = ex.getMessage(); MessageBox.Show(error); } } } else { MessageBox.Show("Please select a valid audio file"); } }
static void Main(string[] args) { String originalFilePath = @"..\..\testFiles\hide.txt"; String extractedFilePath = @"..\..\testFiles\extract"; String savePath = @"..\..\testFiles\save.png"; Bitmap originalImage = (Bitmap)Bitmap.FromFile(@"..\..\testFiles\test.png"); Bitmap steganoImage; steganoImage = SteganoBMP.Embed(originalImage, originalFilePath); EncoderParameters encoderParams = new EncoderParameters(1); EncoderParameter encoderP = new EncoderParameter(Encoder.Quality, 100L); encoderParams.Param[0] = encoderP; steganoImage.Save(savePath, GetEncoder(ImageFormat.Png), encoderParams); string extension; byte[] file = SteganoBMP.Extract(steganoImage, out extension); File.WriteAllBytes(extractedFilePath + "." + extension, file); Console.Write("Done. Press any key."); Console.ReadLine(); String orFilePath = @"..\..\testFiles\blub.txt"; String sPath = @"..\..\testFiles\resultJungle.wav"; String waveFile = @"..\..\testFiles\WelcometotheJungle.wav"; byte[] resultBytes = SteganoWav.Embed(waveFile, orFilePath); File.WriteAllBytes(sPath, resultBytes); byte[] originalBytes = SteganoWav.Extract(sPath); File.WriteAllBytes(@"..\..\testFiles\resulttext." + SteganoWav.Extention, originalBytes); Console.ReadLine(); }
private void BtnExtract_Click(object sender, RoutedEventArgs e) { SaveFileDialog sDialog = new SaveFileDialog(); try { byte[] resultMessage = SteganoWav.Extract(_extractString); string extention = SteganoWav.Extention; sDialog.Filter = "(*." + extention + ")|*" + extention; sDialog.DefaultExt = extention; sDialog.AddExtension = true; Nullable <bool> result = sDialog.ShowDialog(); if (result == true) { _outputMessageFilepath = sDialog.FileName; File.WriteAllBytes(_outputMessageFilepath, resultMessage); BtnOpenMessageFile.IsEnabled = true; } } catch (FileNotFoundException fileNotFoundException) { MessageBox.Show(fileNotFoundException.Message); } catch (ArithmeticException arithmeticException) { MessageBox.Show(arithmeticException.Message); } catch (FileTooLargeException fileTooLargeException) { MessageBox.Show(fileTooLargeException.Message); } catch (ArgumentException argumentException) { MessageBox.Show(argumentException.Message); } }