Beispiel #1
0
        private void btnDecode_Click_1(object sender, EventArgs e)
        {
            bmp = (Bitmap)imgPicture1.Image;
            String plaintext = "";

            if (txtFilelocation1.Text == String.Empty)
            {
                MessageBox.Show("Please choose image to Steganography!", "Warring!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (txtPass1.Text == String.Empty)
            {
                MessageBox.Show("Password is empty!!", "Warring!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            string textmahoa = LSB.extractText(bmp);

            try
            {
                plaintext = Mahoa.DecryptPass(textmahoa, txtPass1.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Password is wrong!");
                return;
            }
            txtDecode.Text = plaintext;
        }
Beispiel #2
0
        private void btnEndcode_Click(object sender, EventArgs e)
        {
            bmp = (Bitmap)imgPicture.Image;
            if (txtFilelocation.Text == String.Empty)
            {
                MessageBox.Show("Please choose image to Steganography!", "Warring!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (txtMessage.Text == String.Empty)
            {
                MessageBox.Show("Message is empty! Please try again.", "Warring!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (txtPass.Text == String.Empty)
            {
                MessageBox.Show("Password is empty! Please try again.", "Warring!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (txtPass.Text.Length < 8)
            {
                MessageBox.Show("Short passwords are easy to guess. Try one with at least 8 characters.", "Warring!", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                return;
            }
            if (txtPass.Text != txtConfirm.Text)
            {
                MessageBox.Show("These passwords don't match!  Please try again.", "Warring!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtConfirm.Text = null;
                return;
            }

            try
            {
                keyEncryp = Mahoa.EncryptPass(txtMessage.Text, txtPass.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Short passwords are easy to guess. Try one with at least 8 characters.", "Warring!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            bmp = LSB.MahoaLSB(keyEncryp, bmp);

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



            #region
            SaveFileDialog saveFile = new SaveFileDialog();
            saveFile.Filter = "Png Image|*.png|Jpg Imgae|*.jpg|Bitmap Image|*.bmp";
            //saveFile.InitialDirectory = @"C:\User\metech\Desktop";
            if (saveFile.ShowDialog() == DialogResult.OK)
            {
                switch (saveFile.FilterIndex)
                {
                case 1:
                {
                    bmp.Save(saveFile.FileName, ImageFormat.Png);
                    break;
                }

                case 2:
                {
                    bmp.Save(saveFile.FileName, ImageFormat.Jpeg);
                    break;
                }

                case 3: {
                    bmp.Save(saveFile.FileName, ImageFormat.Bmp);
                    break;
                }
                }


                NoteLable.Text      = "   Save image successfully!! [Nguyen Thanh Nam , N14DCAT094]";
                NoteLable.ForeColor = Color.Yellow;
                #endregion
            }
        }