public void ExtractFileTemp(int index, string destination)
        {
            var datab = AESThenHMAC.SimpleDecryptWithPassword(this.Files[index].data, this.Key);

            FS = new FileStream(destination, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite, 4096, FileOptions.DeleteOnClose);

            FS.Write(datab, 0, datab.Length);
            Process.Start(destination);
        }
        /// <summary>
        /// Loads a container
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public static CSFContainer Load(string filename, string key, bool loadHidden = false)
        {
            var container = new CSFContainer(key);

            container.hiddenContainerLoaded = loadHidden;

            var buffer = ReadFileBytes(filename);

            container.Path = filename;
            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);
        }
        /// <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);
        }