Esempio n. 1
0
        private string dataDecoding(StegModel stegModel)
        {
            // Log unsteg data
            _log.Debug("---------------------------------------------------------------------------------");
            _log.Debug("Unstegged data:");
            _log.Debug($"Content Size: {stegModel.ContentSize}");
            _log.Debug($"Steg Content: {stegModel.Content.ToDigitString()}");
            _log.Debug($"Full Size: {stegModel.TotalSize}");
            _log.Debug($"Full Content: {stegModel.ContentFull.ToDigitString()}");
            _log.Debug("---------------------------------------------------------------------------------");

            string msg;

            if (stegModel.IsFile)
            {
                var filename        = string.IsNullOrEmpty(txtDecFileName.Text.Trim()) ? "file" : txtDecFileName.Text;
                var docPath         = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                var fileNameAndPath = $@"{docPath}\StegImageUI\Docs\steg_{DateTime.Now.ToString("yyyyMMddHHmmss")}_{filename}";
                try
                {
                    msg = CompressionHelper.Unzip(stegModel.Content, true, fileNameAndPath);
                }
                catch (Exception ex)
                {
                    _log.Debug(ex.Message);
                    MessageBox.Show(ex.Message, "StegImageUI", MessageBoxButton.OK, MessageBoxImage.Error);
                    msg = null;
                }
            }
            else
            {
                try
                {
                    msg = CompressionHelper.Unzip(stegModel.Content);
                }
                catch (Exception ex)
                {
                    _log.Debug(ex.Message);
                    MessageBox.Show(ex.Message, "StegImageUI", MessageBoxButton.OK, MessageBoxImage.Error);
                    msg = null;
                }
            }

            return(msg);
        }
Esempio n. 2
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);
        }