示例#1
0
        /// <summary>
        /// Hides message into .avi file
        /// </summary>
        /// <param name="avifh">.avi file handler</param>
        /// <param name="message">String to hide</param>
        /// <param name="force">Hide into compressed streams</param>
        /// <param name="hideTo">List of streams the message will be hidden into (in given order)</param>
        /// <returns>True if message was hide successfuly else false</returns>
        public static bool HideMessage(AVIFileHandler avifh, string message, bool force, IEnumerable <Options.DataTypes> hideTo)
        {
            message += MESSAGE_END;

            if (!CheckAvailableSpace(avifh, message, hideTo))
            {
                IOUtils.ConsolePrintFailure();
                Console.WriteLine("There is not enough space for message");
                return(false);
            }
            else
            {
                IOUtils.ConsolePrintSuccess();
                Console.WriteLine("Space check.");
            }

            foreach (Options.DataTypes type in hideTo)
            {
                Dictionary <Int32, CHUNK> chunks;

                if (CheckCompression(avifh.IsStreamUncompressed(type), force, type))
                {
                    if (avifh.Chunks.TryGetValue(AVIFileHandler.GetChunkName(type), out chunks))
                    {
                        foreach (KeyValuePair <Int32, CHUNK> kvp in chunks)
                        {
                            message = HideData(avifh.Avi, kvp.Key, kvp.Value.ckSize, message);
                            if (message == String.Empty)
                            {
                                return(true);
                            }
                        }
                    }
                }
            }

            return(false);
        }
示例#2
0
        /// <summary>
        /// Extracts hidden message from .avi file
        /// </summary>
        /// <param name="avifh">.avi file handler</param>
        /// <param name="extractFrom">List of streams the message will be extracted from (in given order)</param>
        /// <returns>Extracted message</returns>
        public static string ExtractMessage(AVIFileHandler avifh, IEnumerable <Options.DataTypes> extractFrom)
        {
            string message    = "";
            bool   EndReached = false;

            foreach (Options.DataTypes type in extractFrom)
            {
                Dictionary <Int32, CHUNK> chunks;
                if (avifh.Chunks.TryGetValue(AVIFileHandler.GetChunkName(type), out chunks))
                {
                    foreach (KeyValuePair <Int32, CHUNK> kvp in chunks)
                    {
                        EndReached = ExtractData(avifh.Avi, kvp.Key, kvp.Value.ckSize, ref message);
                        if (EndReached)
                        {
                            return(message);
                        }
                    }
                }
            }

            return(null);
        }