/** * Makes an array of 4 bytes from ciphered float saves into a file */ private void BtnCipher_Click(object sender, RoutedEventArgs e) { try { WAVHeader cipheredFile = wavHeader; Cipher cipher = new Cipher(cipheredFile.WavData.OriginalData); float[] encoded = cipher.getCipheredData(); cipheredFile.WavData.DataToSave = cipheredFile.WavData.Normalize(encoded); WAVWriter wavWriter = new WAVWriter(); wavWriter.WriteWAVFile(cipheredFile); System.Windows.MessageBox.Show("Plik zostal zaszyfrowany i zapisany do pliku."); } catch (Exception ex) { System.Windows.MessageBox.Show("Najpierw trzeba wczytac plik."); } }
/** * Loads ciphered file, groups 4 bytes into a float, decipheres it and saves into a file */ private void BtnDecipher_Click(object sender, RoutedEventArgs e) { try { WAVHeader cipheredFile = new WAVReader("./cipher.wav", true).ReadWAVFile(); Cipher cipher = new Cipher(cipheredFile.WavData.OriginalData); float[] deciphered = cipher.getDecipheredData(cipheredFile.WavData.OriginalData); cipheredFile.WavData.DataToSave = cipheredFile.WavData.Denormalize(deciphered); WAVWriter wavWriter = new WAVWriter("decipher.wav"); wavWriter.WriteWAVFile(cipheredFile); System.Windows.MessageBox.Show("Plik zostal odszyfrowany i zapisany do pliku."); } catch (Exception ex) { System.Windows.MessageBox.Show("Najpierw trzeba wczytac plik."); } }