/// <summary>
        /// Adds a new file to the container
        /// </summary>
        /// <param name="path"></param>
        public void AddFile(string path)
        {
            if (this.Files.ElementAt(0).Name == "The container is empty")
            {
                this.Files.RemoveAt(0);
            }

            FileInfo info = new FileInfo(path);

            CFile cfile = new CFile {
                Name = info.Name, Length = (int)info.Length, Offset = this.nextOffset, data = AESThenHMAC.SimpleEncryptWithPassword(ReadFileBytes(path), this.Key), Dummy = false
            };

            cfile.Length = cfile.data.Length;

            this.Files.Add(cfile);

            this.Save();

            nextOffset += (int)cfile.Length;

            if (this.addRandomBuffers)
            {
                int randSize = (int)(cfile.Length * (0.05f + new Random().NextDouble() / 10f));
                var data     = AESThenHMAC.SimpleEncryptWithPassword(CreateArrayWithRandomContent(randSize), this.Key);
                var dummy    = new CFile {
                    Name = "", Length = data.Length, Offset = this.nextOffset, data = data, Dummy = true
                };
                this.Files.Add(dummy);
                this.Save();
                nextOffset += (int)dummy.Length;
            }
        }
        /// <summary>
        /// Extracts a filed from the container at the specified index.
        /// </summary>
        /// <param name="index"></param>
        /// <param name="destination"></param>
        public void ExtractFile(int index, string destination)
        {
            var datab = AESThenHMAC.SimpleDecryptWithPassword(this.Files[index].data, this.Key);

            File.WriteAllBytes(destination, datab);
        }
        public static CSFContainer LocalLoad(byte[] Localcontainer, string key, string path, bool loadHidden = false)
        {
            var container = new CSFContainer(key);

            container.hiddenContainerLoaded = loadHidden;

            var buffer = Localcontainer;



            container.Path = path;
            int sizeHeader1 = BitConverter.ToInt32(new byte[4] {
                buffer[0], buffer[1], buffer[2], buffer[3]
            }, 0);
            int sizeHeader2 = BitConverter.ToInt32(new byte[4] {
                buffer[4], buffer[5], buffer[6], buffer[7]
            }, 0);

            container.HeaderSize = sizeHeader1;

            // Get the header
            var header1 = new byte[sizeHeader1];

            for (int i = 0; i < sizeHeader1; i++)
            {
                header1[i] = buffer[i + 8];
            }

            var header2 = new byte[sizeHeader2];

            for (int i = 0; i < sizeHeader2; i++)
            {
                header2[i] = buffer[25000 + i + 8];
            }

            container.header1 = header1;
            container.header2 = header2;

            byte[] header = null;
            if (loadHidden)
            {
                header = AESThenHMAC.SimpleDecryptWithPassword(header2, container.Key);
            }
            else
            {
                header = AESThenHMAC.SimpleDecryptWithPassword(header1, container.Key);
            }

            string header_str = ByteArrayToString(header);

            if (header_str == "empty")
            {
                return(container);
            }

            var lines = header_str.Split("\n".ToCharArray());

            foreach (var line in lines)
            {
                if (line.Trim().Length == 0)
                {
                    continue;
                }

                var separated = line.Split("|".ToCharArray());


                var offset = int.Parse(separated[1]);
                var len    = int.Parse(separated[2]);
                var data   = new byte[len];
                Array.Copy(buffer, offset, data, 0, len);
                container.Files.Add(new CFile {
                    Name = separated[0], Offset = offset, Length = len, data = data, Dummy = ((separated[3] == "dummy") ? true : false)
                });
            }

            container.nextOffset = buffer.Length;



            return(container);
        }