Пример #1
0
        private void BtnHideBMP_Click(object sender, RoutedEventArgs e)
        {
            if (targetPathBMP != "" && inputPathBMP != "")
            {
                try
                {
                    Bitmap embedded = SteganoBMP.Embed(targetPathBMP, inputPathBMP);

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

                    bool?result = save.ShowDialog();

                    if (result == true)
                    {
                        string savePath = save.FileName;

                        EncoderParameters encoderParams = new EncoderParameters(1);
                        EncoderParameter  encoderP      = new EncoderParameter(Encoder.Quality, 100L);
                        encoderParams.Param[0] = encoderP;

                        embedded.Save(savePath, GetEncoder(savePath.Split('.').Last()), encoderParams);

                        embedded.Dispose();
                        showImages(targetPathBMP, savePath);
                    }
                }
                catch (FileTooLargeException fileTooLargeException)
                {
                    MessageBox.Show(fileTooLargeException.Message);
                }
            }
        }
Пример #2
0
        private void btnDesOutputBitmap_Click(object sender, RoutedEventArgs e)
        {
            desTargetPathBMP = txtDesBitmap.Text;
            if (!desTargetPathBMP.Equals(""))
            {
                SaveFileDialog save = new SaveFileDialog();
                save.Filter = "Bitmap Image (.bmp)|*.bmp|Png Image (.png)|*.png";

                bool?result = save.ShowDialog();

                if (result == true)
                {
                    java.lang.Class clazz = typeof(Encryption);
                    java.lang.Thread.currentThread().setContextClassLoader(clazz.getClassLoader());

                    String outputFile = save.FileName;
                    try
                    {
                        if (Encryption.encrypt(encryptionFile, "encryptForBMP", keyFile, EncryptionMode.ENCRYPT) == java.lang.Boolean.TRUE)
                        {
                            Bitmap embedded = SteganoBMP.Embed(desTargetPathBMP, "encryptForBMP.des");
                            String savePath = save.FileName;

                            EncoderParameters encoderParams = new EncoderParameters(1);
                            EncoderParameter  encoderP      = new EncoderParameter(Encoder.Quality, 100L);
                            encoderParams.Param[0] = encoderP;

                            embedded.Save(savePath, GetEncoder(savePath.Split('.').Last()), encoderParams);

                            embedded.Dispose();
                            File.Delete("encryptForBMP.des");
                            MessageBox.Show("File successfully encrypted to image file");
                        }
                    }
                    catch (java.io.IOException ex)
                    {
                        String error = ex.getMessage();
                        MessageBox.Show(error);
                    }
                    catch (FileTooLargeException fileTooLargeException)
                    {
                        MessageBox.Show(fileTooLargeException.Message);
                    }
                }
            }
            else
            {
                MessageBox.Show("Please select a valid image file");
            }
        }
Пример #3
0
        private void BtnExtractFromCarrier_Click(object sender, RoutedEventArgs e)
        {
            if (ExtractPathBMP != "" && ExtractTargetPathBMP != "")
            {
                string extension;

                byte[] extracted = SteganoBMP.Extract(ExtractPathBMP, out extension);

                string savePath = ExtractTargetPathBMP + "\\Extracted." + extension;

                File.WriteAllBytes(savePath, extracted);

                Process.Start(savePath);
            }
        }
Пример #4
0
        private void btnDesOutputBitmapExtract_Click(object sender, RoutedEventArgs e)
        {
            desTargetPathBMPExtract = txtDesBitmapExtract.Text;
            if (!desTargetPathBMPExtract.Equals(""))
            {
                SaveFileDialog save = new SaveFileDialog();
                save.Filter = "All files (*.*)|*.*";

                bool?result = save.ShowDialog();

                if (result == true)
                {
                    String extension;
                    byte[] extracted = SteganoBMP.Extract(desTargetPathBMPExtract, out extension);
                    string savePath  = "extractedMessage." + extension;
                    File.WriteAllBytes(savePath, extracted);

                    java.lang.Class clazz = typeof(Encryption);
                    java.lang.Thread.currentThread().setContextClassLoader(clazz.getClassLoader());

                    String outputFile = save.FileName;
                    try
                    {
                        if (Encryption.encrypt("extractedMessage.des", outputFile, keyFile, EncryptionMode.DECRYPT) == java.lang.Boolean.TRUE)
                        {
                            File.Delete("extractedMessage.des");
                            MessageBox.Show("File successfully decrypted from image file");
                        }
                    }
                    catch (java.io.IOException ex)
                    {
                        String error = ex.getMessage();
                        MessageBox.Show(error);
                    }
                }
            }
            else
            {
                MessageBox.Show("Please select a valid image file");
            }
        }
Пример #5
0
        static void Main(string[] args)
        {
            String originalFilePath  = @"..\..\testFiles\hide.txt";
            String extractedFilePath = @"..\..\testFiles\extract";
            String savePath          = @"..\..\testFiles\save.png";
            Bitmap originalImage     = (Bitmap)Bitmap.FromFile(@"..\..\testFiles\test.png");
            Bitmap steganoImage;

            steganoImage = SteganoBMP.Embed(originalImage, originalFilePath);

            EncoderParameters encoderParams = new EncoderParameters(1);
            EncoderParameter  encoderP      = new EncoderParameter(Encoder.Quality, 100L);

            encoderParams.Param[0] = encoderP;

            steganoImage.Save(savePath, GetEncoder(ImageFormat.Png), encoderParams);

            string extension;

            byte[] file = SteganoBMP.Extract(steganoImage, out extension);

            File.WriteAllBytes(extractedFilePath + "." + extension, file);

            Console.Write("Done. Press any key.");
            Console.ReadLine();

            String orFilePath = @"..\..\testFiles\blub.txt";
            String sPath      = @"..\..\testFiles\resultJungle.wav";
            String waveFile   = @"..\..\testFiles\WelcometotheJungle.wav";

            byte[] resultBytes = SteganoWav.Embed(waveFile, orFilePath);
            File.WriteAllBytes(sPath, resultBytes);



            byte[] originalBytes = SteganoWav.Extract(sPath);
            File.WriteAllBytes(@"..\..\testFiles\resulttext." + SteganoWav.Extention, originalBytes);
            Console.ReadLine();
        }
Пример #6
0
        unsafe private BitmapImage CalculateDiff(String embeddedPath, String originalPath)
        {
            using (Bitmap original = new Bitmap(originalPath))
                using (Bitmap embedded = new Bitmap(embeddedPath))
                    using (Bitmap diff = new Bitmap(original.Width, original.Height))
                    {
                        BitmapData dataOrig  = SteganoBMP.PrepareImage(original);
                        BitmapData dataEmbed = SteganoBMP.PrepareImage(embedded);
                        BitmapData dataDiff  = SteganoBMP.PrepareImage(diff);

                        byte *ptrOrig  = (byte *)dataOrig.Scan0;
                        byte *ptrEmbed = (byte *)dataEmbed.Scan0;
                        byte *ptrDiff  = (byte *)dataDiff.Scan0;

                        int bytes = dataOrig.Stride * dataOrig.Height;

                        byte diffValue = 1;

                        if (chkAmplify.IsChecked == true)
                        {
                            diffValue = 255;
                        }

                        for (int i = 0; i < bytes; i++)
                        {
                            if (ptrOrig[i] != ptrEmbed[i])
                            {
                                ptrDiff[i] = diffValue;
                            }
                        }

                        original.UnlockBits(dataOrig);
                        embedded.UnlockBits(dataEmbed);
                        diff.UnlockBits(dataDiff);

                        return(Bitmap2BitmapImage(diff));
                    }
        }