Example #1
0
        private void downloadBtn_Click(object sender, EventArgs e)
        {
            //Hide Text
            string text     = DataAsGuard.CSClass.Logininfo.username;
            string password = "******";

            bmp  = (Bitmap)showPic.Image;
            text = Crypto.EncryptStringAES(text, password);
            bmp  = SteganographyHelper.embedText(text, bmp);

            //Save image
            SaveFileDialog save_dialog = new SaveFileDialog();

            save_dialog.Filter = "Png Image|*.png|Bitmap Image|*.bmp";

            if (save_dialog.ShowDialog() == DialogResult.OK)
            {
                switch (save_dialog.FilterIndex)
                {
                case 0:
                {
                    bmp.Save(save_dialog.FileName, ImageFormat.Png);
                }
                break;

                case 1:
                {
                    bmp.Save(save_dialog.FileName, ImageFormat.Bmp);
                }
                break;
                }
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                Application.DoEvents();
                System.Threading.Thread.Sleep(1500);
                string fpath = Application.StartupPath + "\\Image\\encryptedText.txt";
                EncryptFile(pictureBox1.Image, fpath);
                string fpath1 = Application.StartupPath + "\\Image\\encrypted.jpg";
                EncryptFile(pictureBox1.Image, fpath1);
                string text = File.ReadAllText(textBox1.Text);
                bmp1 = new Bitmap(Bitmap.FromFile(Application.StartupPath + "\\input\\blank.jpg"));
                bmp  = SteganographyHelper.embedText(text, bmp1);
                bmp.Save(Application.StartupPath + "\\Image\\EncryptedImage.jpg", ImageFormat.Jpeg); // Save the encrypted image
                panelCanvas.Image = Image.FromFile(Application.StartupPath + "\\Image\\EncryptedImage.jpg");
                Application.DoEvents();
                System.Threading.Thread.Sleep(1500);
                Cipher_text = Encrypt_text(txt_plain_text.Text, key);

                con.Open();
                cmd = new SqlCommand("insert into encryption values('" + txt_plain_text.Text + "','" + key + "','" + Cipher_text + "')", con);
                cmd.ExecuteNonQuery();
                con.Close();

                MessageBox.Show("Input Image and Text Encrypted  Successfully");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            string encrypted = StringCipher.Encrypt(textBox1.Text, ConfigurationManager.AppSettings["secret"]);

            pictureBox2.Image = SteganographyHelper.embedText(encrypted, new Bitmap(pictureBox1.Image));
        }
Example #4
0
 /// <summary>
 /// Método responsável pela captura das imagens
 /// O nome de imagem capturada é adiciona numa lista que, posteriormente, é percorrida para enviar as imagens para a pasta destino
 /// </summary>
 private void CreatePrintScreen()
 {
     Seq += 1;
     // Sequência
     ScreenCapturing.LegendData.FrameID = Seq;
     // Captura a tela
     Image[] imgList;
     if (sysConfig.Data.OneImagePerScreen)
     {
         imgList = ScreenCapturing.GetDesktopWindowCaptureAsBitmaps();
     }
     else
     {
         // Captura uma única imagem para todos monitores
         imgList    = new Image[1];
         imgList[0] = ScreenCapturing.GetDesktopWindowCaptureAsBitmap();
     }
     for (int i = 0; i < imgList.Length; i++)
     {
         Image tempImg = imgList[i];
         try
         {
             // Nome do arquivo
             string fileToSave = Environment.UserName + DATA_DELIMITER +
                                 MACAddress + DATA_DELIMITER +
                                 Util.GetLocalIpAddress() + DATA_DELIMITER +
                                 string.Format("{0:yyyyMMdd_HH_mm_ss_fff}", internalClock) + DATA_DELIMITER +
                                 i.ToString() +
                                 sysConfig.Data.ExtImgFormat;
             // No do arquivo temporário (com path)
             string tempFullFileToSave = sysConfig.TempPath + fileToSave;
             // Adiciona assinatura com dados de segurança na imagem quando a imagem for PNG
             if ((sysConfig.Data.ImgFormat == ImageFormat.Png) && (sysConfig.Data.UseSignature))
             {
                 // Pabavra chave de segurança e identificação que é embutida na imagem
                 string wordSecurity = UDYATSIGN + DATA_DELIMITER +
                                       sysConfig.Data.CustomerID.ToString() + DATA_DELIMITER +
                                       sysConfig.Data.CustomerMacNumber.ToString() + DATA_DELIMITER +
                                       FnvHash.GetHash(sysConfig.Data.CustomerWord, 120).ToHexString() + DATA_DELIMITER +
                                       sysConfig.MachineUniqueID + DATA_DELIMITER +
                                       fileToSave;
                 // Esconde o texto na imagem (esteganografia)
                 SteganographyHelper.embedText(wordSecurity, (Bitmap)tempImg);
             }
             // Salva o arquivo no Temp
             if (sysConfig.Data.ImgFormat == ImageFormat.Jpeg)
             {
                 tempImg.Save(tempFullFileToSave, sysConfig.Data.ImageCodec, sysConfig.Data.EncoderParams);
             }
             else
             {
                 tempImg.Save(tempFullFileToSave, sysConfig.Data.ImgFormat);
             }
             // Adiciona o arquivo na lista de arquivos que devem ser movidos
             if (sysConfig.Data.MoveImagesToTarget)
             {
                 lock (filesToSend.SyncRoot)
                 {
                     filesToSend.Add(fileToSave);
                 }
             }
         }
         catch (Exception ex)
         {
             Log.AddLog("Captura", ex.Message);
         }
     }
 }
        private void hide_Click(object sender, EventArgs e)
        {
            if (container_size < this.image_max_info)
            {
                string finalText = ByteArrayToString(containerBytes);
                string textTemp  = null;


                bool last            = false;
                int  image_Totalsize = 0;



                for (int x = 0; x < files.Count(); x++)
                {
                    finalText       = x.ToString() + " " + finalText;
                    image_Totalsize = image_size(files.ElementAt(x));

                    if (image_Totalsize > finalText.Length)
                    {
                        if (last)
                        {
                            finalText = x.ToString() + " ";
                        }
                        else
                        {
                            textTemp = finalText;
                        }

                        String name = "Photo" + x.ToString() + ".png";
                        image_final = SteganographyHelper.embedText(textTemp, files.ElementAt(x));
                        image_final.Save(@"C:\Users\Blotz\Desktop\" + name, ImageFormat.Png);
                        finalText = "";
                        last      = true;
                    }
                    else
                    {
                        textTemp  = finalText.Substring(0, image_Totalsize);
                        finalText = finalText.Substring(image_Totalsize);

                        String name = "Photo" + x.ToString() + ".png";
                        image_final = SteganographyHelper.embedText(textTemp, files.ElementAt(x));
                        image_final.Save(@"C:\Users\Blotz\Desktop\" + name, ImageFormat.Png);
                    }
                }

                this.files.Clear();
                imageList1.Images.Clear();



                //SaveFileDialog save_dialog = new SaveFileDialog();
                //save_dialog.Filter = "Png Image|*.png|Bitmap Image|*.bmp";

                //if (save_dialog.ShowDialog() == DialogResult.OK)
                //{
                //    switch (save_dialog.FilterIndex)
                //    {
                //        case 0:
                //            {
                //                image_final.Save(save_dialog.FileName, ImageFormat.Png);
                //            }
                //            break;
                //        case 1:
                //            {
                //                image_final.Save(save_dialog.FileName, ImageFormat.Bmp);
                //            }
                //            break;
                //    }

                //}

                MessageBox.Show("DONE!");
            }
            else
            {
                MessageBox.Show("Error: Not enough images for the size of the container. Please add more images");
            }
        }