Example #1
0
        private void EncodeMessage()
        {
            Bitmap bitmap = (Bitmap)imagePictureBox.BackgroundImage;

            if (!String.IsNullOrEmpty(messageTextBox.Text))
            {
                if ((bool)encryptTextCheckBox.IsChecked)
                {
                    if (!String.IsNullOrEmpty(passwordTextBox.Password))
                    {
                        try
                        {
                            string encryptedText = Crypto.EncryptStringAES(messageTextBox.Text, passwordTextBox.Password);
                            bitmap = StegHelper.EmbedText(encryptedText, bitmap);
                            SaveFile(bitmap);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("An error occurred\n" + ex.Message);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please enter a password");
                    }
                }
                else
                {
                    string           message = "Do you not want to encrypt the text to be saved in the image by using a password?";
                    MessageBoxResult result  = System.Windows.MessageBox.Show(message, "Information", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.None, System.Windows.MessageBoxOptions.DefaultDesktopOnly);
                    switch (result)
                    {
                    case MessageBoxResult.Yes:
                        encryptTextCheckBox.IsChecked = true;
                        System.Windows.MessageBox.Show("Please enter a password", "Enter password", MessageBoxButton.OK, MessageBoxImage.Information);
                        break;

                    case MessageBoxResult.No:
                        encryptTextCheckBox.IsChecked = false;
                        StegHelper.EmbedText(messageTextBox.Text, bitmap);
                        SaveFile(bitmap);
                        break;
                    }
                    ;
                }
            }
            else
            {
                MessageBox.Show("Please enter message or load message");
            }
        }
Example #2
0
        private void sendEncodedImageButton_Click(object sender, RoutedEventArgs e)
        {
            Bitmap bitmap = (Bitmap)emailImagePictureBox.BackgroundImage;

            if (!String.IsNullOrEmpty(emailMessageTextBox.Text))
            {
                if ((bool)emailEncryptTextCheckBox.IsChecked)
                {
                    if (!String.IsNullOrEmpty(emailPasswordTextBox.Password))
                    {
                        if (!String.IsNullOrEmpty(emailMessageSubjectTextBox.Text) && !String.IsNullOrEmpty(emailMessageBodyTextBox.Text))
                        {
                            //try
                            //{
                            string encryptedText = Crypto.EncryptStringAES(emailMessageTextBox.Text, emailPasswordTextBox.Password);
                            bitmap = StegHelper.EmbedText(encryptedText, bitmap);
                            SendImageWithAttachment(emailMessageSubjectTextBox.Text, emailMessageSubjectTextBox.Text, bitmap);

                            /*}
                             * catch (Exception ex)
                             * {
                             *  MessageBox.Show("An error occurred\n");
                             * }*/
                        }
                        else
                        {
                            MessageBox.Show("Please enter message into subject and body of email");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please enter a password");
                    }
                }
                else
                {
                    //Just send without encryption
                }
            }
            else
            {
                MessageBox.Show("Please enter a message to encode into image");
            }
        }
Example #3
0
        private void decodeButton_Click(object sender, RoutedEventArgs e)
        {
            Bitmap bitmap = (Bitmap)decodeImagePictureBox.BackgroundImage;

            if (decodeImagePictureBox.BackgroundImage != null)
            {
                if ((bool)decryptTextCheckBox.IsChecked)
                {
                    if (!String.IsNullOrEmpty(decodePasswordTextBox.Password))
                    {
                        string extractedEncryptedText = StegHelper.ExtractText(bitmap);
                        try
                        {
                            string extractText = Crypto.DecryptStringAES(extractedEncryptedText, decodePasswordTextBox.Password);
                            decodeMessageTextBox.Text = extractText;
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(String.Format("Wrong password", ex.Message));
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please enter a password");
                    }
                }
                else
                {
                    decodeMessageTextBox.Text = StegHelper.ExtractText(bitmap);
                }
            }
            else
            {
                MessageBox.Show("Please select an image");
            }
        }