Ejemplo n.º 1
0
        private static void stegImageByImageType(string path, BitArray baBits, int securityLevel)
        {
            var trimPath = path.ToLower().Trim();

            // Check image type
            if (trimPath.EndsWith(".jpg") || trimPath.EndsWith(".jpeg")) // JPEG
            {
                JpegHelper.StegBinary(path, baBits, securityLevel);
            }
            else if (trimPath.EndsWith(".bmp")) // BITMAP
            {
                BmpHelper.StegBinary(path, baBits, securityLevel);
            }
            else if (trimPath.EndsWith(".png")) // PNG
            {
                PngHelper.StegBinary(path, baBits, securityLevel);
            }
            else if (trimPath.EndsWith(".gif")) // GIF
            {
                GifHelper.StegBinary(path, baBits);
            }
            else if (trimPath.EndsWith(".tif") || trimPath.EndsWith(".tiff")) // TIFF
            {
                TifHelper.StegBinary(path, baBits, securityLevel);
            }
            else if (!string.IsNullOrEmpty(trimPath))
            {
                MessageBox.Show("Wrong extension.", "StegImageUI", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Ejemplo n.º 2
0
        private void getSlotsByImageType(string imagePath)
        {
            var trimPath = imagePath.ToLower().Trim();

            // Check image type
            if (trimPath.EndsWith(".jpg") || trimPath.EndsWith(".jpeg")) // JPEG
            {
                // Available slots not 0 - DCT values 0 won't be overwritten
                var dctCoeffs = JpegHelper.GetDctCoefficients(imagePath);
                // 2 bits for each dct coefficient (0 values are skpped)
                _slots = 2 * dctCoeffs.DctFullAc.Where(s => 0 != s).Count() - HEADER_BITS_LEN;
            }
            else if (trimPath.EndsWith(".bmp")) // BITMAP
            {
                _slots = BmpHelper.GetAvailableSlots(imagePath) - HEADER_BITS_LEN;
            }
            else if (trimPath.EndsWith(".png")) // PNG
            {
                _slots = PngHelper.GetAvailableSlots(imagePath) - HEADER_BITS_LEN;
            }
            else if (trimPath.EndsWith(".gif")) // GIF
            {
                sldSecLevel.Value = 1;
                _slots            = GifHelper.GetAvailableSlots(imagePath) - HEADER_BITS_IDX_LEN;
            }
            else if (trimPath.EndsWith(".tif") || trimPath.EndsWith(".tiff")) // TIFF
            {
                sldSecLevel.Value = 1;
                _slots            = TifHelper.GetAvailableSlots(imagePath) - HEADER_BITS_IDX_LEN;
            }
            if (_slots < 10)
            {
                tbxSlots.Text = tbxSlotsUsed.Text = tbxSlotsLeft.Text = "0";
                MessageBox.Show("Image not suitable for embedding content.", "StegImageUI", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Ejemplo n.º 3
0
        private static StegModel unstegImageByImageType(string path)
        {
            var sm       = new StegModel();
            var trimPath = path.ToLower().Trim();

            // Check image type
            if (trimPath.EndsWith(".jpg") || trimPath.EndsWith(".jpeg")) // JPEG
            {
                var stegStruct = JpegHelper.UnstegBinary(path);
                sm.SecurityLevel = stegStruct.SecurityLevel;
                sm.TotalSize     = stegStruct.TotalSize;
                sm.ContentFull   = stegStruct.ContentFull;
                sm.IsFile        = stegStruct.IsFile;
                sm.ContentSize   = stegStruct.ContentSize;
                sm.Content       = stegStruct.Content;
            }
            else if (trimPath.EndsWith(".bmp")) // BITMAP
            {
                var stegStruct = BmpHelper.UnstegBinary(path);
                sm.SecurityLevel = stegStruct.SecurityLevel;
                sm.TotalSize     = stegStruct.TotalSize;
                sm.ContentFull   = stegStruct.ContentFull;
                sm.IsFile        = stegStruct.IsFile;
                sm.ContentSize   = stegStruct.ContentSize;
                sm.Content       = stegStruct.Content;
            }
            else if (trimPath.EndsWith(".png")) // PNG
            {
                var stegStruct = PngHelper.UnstegBinary(path);
                sm.SecurityLevel = stegStruct.SecurityLevel;
                sm.TotalSize     = stegStruct.TotalSize;
                sm.ContentFull   = stegStruct.ContentFull;
                sm.IsFile        = stegStruct.IsFile;
                sm.ContentSize   = stegStruct.ContentSize;
                sm.Content       = stegStruct.Content;
            }
            else if (trimPath.EndsWith(".gif")) // GIF
            {
                var stegStruct = GifHelper.UnstegBinary(path);
                sm.SecurityLevel = stegStruct.SecurityLevel;
                sm.TotalSize     = stegStruct.TotalSize;
                sm.ContentFull   = stegStruct.ContentFull;
                sm.IsFile        = stegStruct.IsFile;
                sm.ContentSize   = stegStruct.ContentSize;
                sm.Content       = stegStruct.Content;
            }
            else if (trimPath.EndsWith(".tif") || trimPath.EndsWith(".tiff")) // TIFF
            {
                var stegStruct = TifHelper.UnstegBinary(path);
                sm.SecurityLevel = stegStruct.SecurityLevel;
                sm.TotalSize     = stegStruct.TotalSize;
                sm.ContentFull   = stegStruct.ContentFull;
                sm.IsFile        = stegStruct.IsFile;
                sm.ContentSize   = stegStruct.ContentSize;
                sm.Content       = stegStruct.Content;
            }

            else if (!string.IsNullOrEmpty(trimPath))
            {
                MessageBox.Show("Wrong extension.", "StegImageUI", MessageBoxButton.OK, MessageBoxImage.Information);
            }

            return(sm);
        }