Example #1
0
        //activate after click hide message button
        private void hideButton_Click(object sender, EventArgs e)
        {
            bmp = (Bitmap)imagePictureBox.Image;



            if (bmp == null)
            {
                MessageBox.Show("No Image file", "Error");

                return;
            }

            int h      = bmp.Height;
            int w      = bmp.Width;
            int pixels = h * w;


            string text = dataTextBox.Text;

            //check whether image is enough to hold the message
            if (pixels * 3 < (text.Length * 8) + 8)
            {
                MessageBox.Show("Image is not enough", "Error");

                return;
            }

            //check message box is empty
            if (text.Equals(""))
            {
                MessageBox.Show("You have not entered any message ", "Error");

                return;
            }
            // check message is greater than 255 characters
            if (text.Length > 255)
            {
                MessageBox.Show("The text is too big !!! Maximum length is 255", "Error");

                return;
            }
            //check message contain invalid chracters
            for (int i = 0; i < text.Length; i++)
            {
                if (text[i] < 32 || text[i] > 125)
                {
                    MessageBox.Show("Message contain invalid character(s)", "Error");
                    return;
                }
            }


            bmp = SteganographyOps.embedText(text, bmp);

            MessageBox.Show("Message was hidden in the image successfully!", "OK");
            dataTextBox.Text = "";
        }
Example #2
0
        //activate after click extract message button
        private void extractButton_Click(object sender, EventArgs e)
        {
            bmp = (Bitmap)imagePictureBox.Image;

            if (bmp == null)
            {
                MessageBox.Show("No Image file", "Error");

                return;
            }

            string extractedText = SteganographyOps.extractText(bmp);

            if (extractedText == null || extractedText.Equals(""))
            {
                MessageBox.Show("Not contain a secret message", "Error");
            }
            else
            {
                dataTextBox.Text = extractedText;
            }
        }