Example #1
0
        private void discoverButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string padFoto = browseVenster.FileName;
                Bitmap bitmap  = new Bitmap(padFoto);

                string extractedText = StenografieHelper.extractText(bitmap);

                if (encrypedCheckBox.IsChecked == true)
                {
                    try
                    {
                        extractedText = StenografieCrypto.DecryptStringAES(extractedText, passwordTextBox.Text);
                    }
                    catch
                    {
                        MessageBox.Show("Wrong password", "Error");

                        return;
                    }
                }
                richTextBox.Text = extractedText;
            }
            catch (Exception exception)
            {
                MessageBox.Show("Something went wrong");
            }
        }
Example #2
0
        private void HideData(object sender, RoutedEventArgs e)
        {
            try
            {
                string _text = richTextBox.Text;

                // string padFoto = labelSelectedImage.Content.ToString();
                Bitmap bitmap = new Bitmap(imagePath);

                if (_text.Equals(""))
                {
                    MessageBox.Show("The text you want to hide can't be empty", "Warning");
                    return;
                }

                if (encrypedCheckBox.IsChecked == true)
                {
                    if (passwordTextBox.Text.Length < 6)
                    {
                        MessageBox.Show("Please enter a password with at least 6 characters", "Warning");
                        return;
                    }
                    else
                    {
                        _text = StenografieCrypto.EncryptStringAES(_text, passwordTextBox.Text);
                    }
                }

                bitmap = StenografieHelper.embedText(_text, bitmap);

                MessageBox.Show("Your text was hidden in the image successfully!", "Done");
                maakLeeg();

                SaveFileDialog save_dialog = new SaveFileDialog();
                save_dialog.Filter = "Png Image|*.png|Bitmap Image|*.bmp";

                if (save_dialog.ShowDialog() == true)
                {
                    switch (save_dialog.FilterIndex)
                    {
                    case 0:
                    {
                        bitmap.Save(save_dialog.FileName, ImageFormat.Png);
                    }
                    break;

                    case 1:
                    {
                        bitmap.Save(save_dialog.FileName, ImageFormat.Bmp);
                    }
                    break;
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Something went wrong");
                // throw;
            }
            finally
            {
                maakLeeg();
            }
        }