public static bool stegoChar(string txt, string fileName, string newFileName, int[] stegoKey, List <bool> compMsg)
        {
            long noChars = WordDocument.noChars(fileName);

            if ((noChars - 1) * 4 < txt.Length * 8)
            {
                return(false);
            }

            List <bool> msg;

            if (compMsg != null)
            {
                msg = compMsg;
            }
            else
            {
                msg = txtToBinary(txt);
            }


            string      coverString = WordDocument.returnDocument(fileName);
            List <char> cover       = coverString.ToCharArray().ToList();

            string stegoText = "";
            int    j         = 0;
            int    k         = 0;

            do
            {
                char pref = cover[k++];
                stegoText += pref;
                if (msg[j++])
                {
                    stegoText += Convert.ToChar(stegoKey[0]);
                }
                if (msg[j++])
                {
                    stegoText += Convert.ToChar(stegoKey[1]);
                }
                if (msg[j++])
                {
                    stegoText += Convert.ToChar(stegoKey[2]);
                }
                if (msg[j++])
                {
                    stegoText += Convert.ToChar(stegoKey[3]);
                }
            } while (k < cover.Count - 1 && j < msg.Count);


            if (k < cover.Count - 1)
            {
                stegoText += coverString.Substring(k);
            }

            WordDocument.createWord(stegoText, newFileName);

            return(true);
        }
        public static string stegoRet(string fileName)
        {
            string      toRet  = "";
            List <bool> binary = new List <bool>();
            string      stego  = WordDocument.returnDocument(fileName);
            List <char> chars;

            chars = stego.ToCharArray().ToList();
            int end  = 0;
            int bajt = 0;
            int i;

            for (i = 0; i < chars.Count; i++)
            {
                if (chars[i] == ' ')
                {
                    if (chars[i + 1] == ' ')
                    {
                        binary.Add(true);
                        i++;
                        end = 0;
                    }
                    else
                    {
                        binary.Add(false);
                        end++;
                        if (end > 7 && bajt == 7)
                        {
                            break;
                        }
                    }
                    bajt = (bajt == 7) ? 0 : bajt + 1;
                }
            }


            i = 0;
            while (i < binary.Count)
            {
                List <bool> oneByte = binary.GetRange(i, 8);
                int         value   = 0;

                for (int j = oneByte.Count - 1; j >= 0; j--)
                {
                    if (oneByte[j])
                    {
                        value += Convert.ToInt16(Math.Pow(2, oneByte.Count - j - 1));
                    }
                }

                toRet += (char)value;
                i     += 8;
            }


            return(toRet);
        }
        public static bool stego(string txt, string fileName, string newFileName)
        {
            int noWords = WordDocument.noWords(fileName);

            if (noWords - 1 < txt.Length * 8)
            {
                return(false);
            }


            List <bool> msg         = txtToBinary(txt);
            string      coverString = WordDocument.returnDocument(fileName);
            List <char> cover       = coverString.ToList();

            string stegoText = "";
            int    j         = 0;
            int    k         = 0;


            do
            {
                char pref = cover[k++];
                if (pref == ' ')
                {
                    if (msg[j])
                    {
                        stegoText += pref + " ";
                    }
                    else
                    {
                        stegoText += pref;
                    }
                    j++;
                }
                else
                {
                    stegoText += pref;
                }
            } while (k < cover.Count - 1 && j < msg.Count);

            if (j < msg.Count)
            {
                if (msg[j])
                {
                    stegoText += "  ";
                }
                else
                {
                    stegoText += " ";
                }
            }
            if (k < cover.Count - 1)
            {
                stegoText += coverString.Substring(k);
            }


            WordDocument.createWord(stegoText, newFileName);

            return(true);
        }
        public static Dictionary <char, int> stegoHuffman(string txt, string fileName, string newFileName)
        {
            List <bool> msg      = new List <bool>();
            HuffmanTree huffTree = new HuffmanTree();

            txt += '\0';
            huffTree.build(txt);
            huffTree.Root.Traverse1();

            List <bool> encoded = huffTree.encode(txt);

            foreach (bool b in encoded)
            {
                msg.Add(b);
            }

            int noWords = WordDocument.noWords(fileName);

            if (noWords - 1 < msg.Count)
            {
                return(null);
            }
            string      coverString = WordDocument.returnDocument(fileName);
            List <char> cover       = coverString.ToCharArray().ToList();

            string stegoText = "";
            int    j         = 0;
            int    k         = 0;


            do
            {
                char pref = cover[k++];
                if (pref == ' ')
                {
                    if (msg[j])
                    {
                        stegoText += pref + " ";
                    }
                    else
                    {
                        stegoText += pref;
                    }
                    j++;
                }
                else
                {
                    stegoText += pref;
                }
            } while (k < cover.Count - 1 && j < msg.Count);

            if (j < msg.Count)
            {
                if (msg[j])
                {
                    stegoText += "  ";
                }
                else
                {
                    stegoText += " ";
                }
            }
            if (k < cover.Count - 1)
            {
                stegoText += coverString.Substring(k);
            }


            WordDocument.createWord(stegoText, newFileName);
            return(huffTree.Frequencies);
        }