private void btnEnkrip_Click(object sender, EventArgs e)
        {
            if  (txtFileWav.Text.Length==0)
            {
                error.SetError(txtFileWav, "Anda harus memasukkan file wav");
            }
            else if (txtKunci.Text.Length == 0)
            {
                error.SetError(txtKunci, "Kunci tidak boleh kosong!");
            }
            else if (txtHslSmbny.Text.Length==0)
            {
                error.SetError(txtHslSmbny, "Hasil enkripsi tidak boleh kosong!.");
            }
            else if (rdoSmbnyiFile.Checked && (txtSmbnyiFile.Text.Length == 0))
            {
                error.SetError(txtSmbnyiFile, "File yang di sembunyikan tidak boleh kosong!");
            }
            else if (rdoPesan.Checked && (txtPesan.Text.Length == 0))
            {
                error.SetError(txtPesan, "Pesan yang di sembunyika tidak boleh kosong!");
            }
            else
            {
                MessageBox.Show("File/Pesan sudah di sembunyikan");
                Stream sourceStream = null;
                FileStream destinationStream = null;
                WaveStream audioStream = null;

                Stream messageStream = GetMessageStream();

                Stream keyStream = new FileStream(txtKunci.Text, FileMode.Open);

                try
                {

                    long countSamplesRequired = WaveUtility.CheckKeyForMessage(keyStream, messageStream.Length);

                    if (countSamplesRequired > Int32.MaxValue)
                    {
                        throw new Exception("Pesan terlalu panjang atau kunci tidak cocok, Kombinasi pesan/kunci membutuhkan" + countSamplesRequired + " Sampel hanya " + Int32.MaxValue + " yang diperbolehkan.");
                    }

                        sourceStream = new FileStream(txtFileWav.Text, FileMode.Open);

                    this.Cursor = Cursors.WaitCursor;

                    destinationStream = new FileStream(txtHslSmbny.Text, FileMode.Create);

                    audioStream = new WaveStream(sourceStream, destinationStream);
                    if (audioStream.Length <= 0)
                    {
                        throw new Exception("File wav gagal");
                    }

                    if (countSamplesRequired > audioStream.CountSamples)
                    {
                        String errorReport = "File terlalu kecil untuk pesan dan kunci\r\n"
                            + "Sampel yang tersedia: " + audioStream.CountSamples + "\r\n"
                            + "Sampel yang dibutuhkan: " + countSamplesRequired;
                        throw new Exception(errorReport);
                    }

                    WaveUtility utility = new WaveUtility(audioStream, destinationStream);
                    utility.Hide(messageStream, keyStream);
                }
                catch (Exception ex)
                {
                    this.Cursor = Cursors.Default;
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    if (keyStream != null) { keyStream.Close(); }
                    if (messageStream != null) { messageStream.Close(); }
                    if (audioStream != null) { audioStream.Close(); }
                    if (sourceStream != null) { sourceStream.Close(); }
                    if (destinationStream != null) { destinationStream.Close(); }
                    this.Cursor = Cursors.Default;
                }
            }
        }
        private void btnTmpl_Click(object sender, EventArgs e)
        {
            if (txtEnkrip.Text.Length == 0)
            {
                error.SetError(txtFileWav, "File Wav Enkrip tidak boleh kososng!");
            }
            else if (txtKunci1.Text.Length == 0)
            {
                error.SetError(txtKunci, "Kunci Tidak Boleh Kosong!");
            }
            else
            {

                this.Cursor = Cursors.WaitCursor;

                FileStream sourceStream = null;
                WaveStream audioStream = null;
                MemoryStream messageStream = new MemoryStream();
                Stream keyStream = new FileStream(txtKunci1.Text, FileMode.Open);

                try
                {

                    sourceStream = new FileStream(txtEnkrip.Text, FileMode.Open);
                    audioStream = new WaveStream(sourceStream);
                    WaveUtility utility = new WaveUtility(audioStream);

                    utility.Extract(messageStream, keyStream);

                    messageStream.Seek(0, SeekOrigin.Begin);
                    if (rdoHslTmpl.Checked)
                    {
                        MessageBox.Show("Pesan Sudah disimpan");
                        FileStream fs = new FileStream(txtHslTmpl.Text, FileMode.Create);

                        byte[] buffer = new byte[messageStream.Length];
                        messageStream.Read(buffer, 0, buffer.Length);
                        fs.Write(buffer, 0, buffer.Length);
                        fs.Close();
                    }
                    else
                    {
                        MessageBox.Show("Pesan Akan ditampilkan");
                        txtTmplPsn.Text = new StreamReader(messageStream).ReadToEnd();
                    }
                }
                catch (Exception ex)
                {
                    this.Cursor = Cursors.Default;
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    if (keyStream != null) { keyStream.Close(); }
                    if (messageStream != null) { messageStream.Close(); }
                    if (audioStream != null) { audioStream.Close(); }
                    if (sourceStream != null) { sourceStream.Close(); }
                    this.Cursor = Cursors.Default;
                }
            }
        }