Exemplo n.º 1
0
        private void btnExtract_Click(object sender, EventArgs e)
        {
            Bitmap bmp           = new Bitmap(picStegImage.Image);
            string extractedText = HideandExtract.extractText(bmp);

            try
            {
                extractedText = crypto.DecryptStringAES(extractedText, txtExtractPassword.Text);
            }
            catch
            {
                MessageBox.Show("Wrong password", "Error");

                return;
            }

            txtextractedText.Text = extractedText;


            //System.IO.MemoryStream ms1 = new System.IO.MemoryStream(cipherbytes);
            //CryptoStream cs1 = new CryptoStream(ms1, desobj.CreateDecryptor(), CryptoStreamMode.Read);

            //cs1.Read(cipherbytes, 0, cipherbytes.Length);
            //plainbytes2 = ms1.ToArray();
            //cs1.Close();
            //ms1.Close();

            //txtextractedText.Text = Encoding.ASCII.GetString(plainbytes2);
        }
Exemplo n.º 2
0
        private void btnEncode_Click_1(object sender, EventArgs e)
        {
            img = new Bitmap(txtFilePath.Text);
            string text = "";

            if (txtPlaintext.Text == "")
            {
                MessageBox.Show("Please enter a text.");
            }

            if (txtPassword.Text.Length < 6)
            {
                MessageBox.Show("Password is too Short.");
                txtPassword.Text = "";
                txtPassword.Focus();
            }
            else
            {
                text = crypto.EncryptStringAES(txtPlaintext.Text, txtPassword.Text);
                //Program.Password = txtPassword.Text;
                //cipherData = txtPlaintext.Text;
                //plainbytes = Encoding.ASCII.GetBytes(cipherData);
                //plainkey = Encoding.ASCII.GetBytes("0123456789abcdef");
                //desobj.Key = plainkey;
                //desobj.Mode = CipherMode.CBC;
                //desobj.Padding = PaddingMode.PKCS7;
                //System.IO.MemoryStream ms = new System.IO.MemoryStream();
                //CryptoStream cs = new CryptoStream(ms, desobj.CreateEncryptor(), CryptoStreamMode.Write);
                //cs.Write(plainbytes, 0, plainbytes.Length);
                //cs.Close();
                //cipherbytes = ms.ToArray();
                //ms.Close();
                //text = (Encoding.ASCII.GetString(cipherbytes));
                txtEcncrypttext.Text = text;
                img = HideandExtract.embedText(text, img);
                MessageBox.Show("Message has been embedded.");
                MessageBox.Show("Please save and continue.");
            }



            //for (int i = 0; i < img.Width; i++)
            //{
            //    for (int j = 0; j < img.Height; j++)
            //    {
            //        Color pixel = img.GetPixel(i, j);

            //        if (i < 1 && j < txtPlaintext.TextLength * 7)
            //        {


            /* Console.WriteLine("R=[" + i + "][" + j + "]=" + pixel.R);
             * Console.WriteLine("G=[" + i + "][" + j + "]=" + pixel.G);
             * Console.WriteLine("B=[" + i + "][" + j + "]=" + pixel.B);
             *
             * char[] PictureR = ConvertIntegerToBinary(pixel.R).ToCharArray();
             * char[] PictureG = ConvertIntegerToBinary(pixel.G).ToCharArray();
             * char[] PictureB = ConvertIntegerToBinary(pixel.B).ToCharArray();
             *
             * foreach (var item in PictureR)
             * {
             *   Console.WriteLine("RBinary:" + item);
             * }
             * foreach (var item in PictureG)
             * {
             *   Console.WriteLine("GBinary:" + item);
             * }
             * foreach (var item in PictureB)
             * {
             *   Console.WriteLine("BBinary:" + item);
             * }
             *
             *
             *
             * char Letter = Convert.ToChar(txtPlaintext.Text.Substring(j, 1));
             *
             *
             *
             * int Value = Convert.ToInt32(Letter);
             * Console.WriteLine("Letter:" + Letter + "Value:" + Value);
             *
             * Console.WriteLine(ConvertIntegerToBinary(Value));
             * char[] text = ConvertIntegerToBinary(Value).ToCharArray();
             * foreach (var item in text)
             * {
             *   Console.WriteLine(item);
             * }*/


            //        }
            //    }
            //}
        }