Exemplo n.º 1
0
        private void btn_decrypt_Click(object sender, EventArgs e)
        {
            String drcryptPassword = txt_decryptPassword.Text.ToString();

            SteganographyHelper helper = new SteganographyHelper();

            try
            {
                string encryptedData = SteganographyHelper.ExtractText(
                    new Bitmap(
                        Image.FromFile(imageToEncrypt)
                        )
                    );

                string decryptedData = StringCipher.Decrypt(encryptedData, drcryptPassword);
                decodedMessage    = decryptedData;
                dect_message.Text = decryptedData;
            }
            catch
            {
                MessageBox.Show("Something went Wrong!");
            }
        }
Exemplo n.º 2
0
        private void btn_encrypt_Click(object sender, EventArgs e)
        {
            String message  = txt_message.Text.ToString();
            String password = txt_password.Text.ToString();

            SteganographyHelper helper = new SteganographyHelper();

            try
            {
                if (imageToEncrypt.Equals(""))
                {
                    MessageBox.Show("Image needs to Hide the Text, Please Select Image and Try Again!");
                }
                else
                {
                    if (message.Equals(""))
                    {
                        MessageBox.Show("Your Message is Empty!");
                    }
                    else
                    {
                        String encryptedMessage = StringCipher.Encrypt(message, password);

                        Bitmap originalImage = new Bitmap(Image.FromFile(imageToEncrypt));

                        Bitmap imageWithHiddenData = SteganographyHelper.MergeText(encryptedMessage, originalImage);

                        SaveFileDialog saveFileDialog = new SaveFileDialog();
                        saveFileDialog.Title            = "Save Encrypted Image";
                        saveFileDialog.CheckFileExists  = false;
                        saveFileDialog.CheckPathExists  = true;
                        saveFileDialog.DefaultExt       = "bmp";
                        saveFileDialog.Filter           = "Bitmap Images (*.bmp)|*.bmp | PNG Image (*.png)|*.png | All files (*.*)|*.*";
                        saveFileDialog.FilterIndex      = 2;
                        saveFileDialog.RestoreDirectory = true;
                        if (saveFileDialog.ShowDialog() == DialogResult.OK)
                        {
                            imageThatEncrypted = saveFileDialog.FileName;

                            if (saveFileDialog.FilterIndex == 1)
                            {
                                imageWithHiddenData.Save(imageThatEncrypted, System.Drawing.Imaging.ImageFormat.Bmp);
                            }
                            else if (saveFileDialog.FilterIndex == 2)
                            {
                                imageWithHiddenData.Save(imageThatEncrypted, System.Drawing.Imaging.ImageFormat.Png);
                            }
                            else
                            {
                                imageWithHiddenData.Save(imageThatEncrypted, System.Drawing.Imaging.ImageFormat.Bmp);
                            }

                            MessageBox.Show("Your Text is Hidden inside the Image");
                        }
                        else
                        {
                            MessageBox.Show("Process Aborted!");
                        }
                    }
                }
            }
            catch
            {
                MessageBox.Show("Your Message is Too length to store inside an Image!");
            }
        }