Esempio n. 1
0
        public CompressionInfo(Stream file, CryptoClass crypto)
        {
            byte[] headBytes = new byte[Header.HeadBegin.Length];
            file.Position = 0;
            file.Read(headBytes, 0, headBytes.Length);

            if (crypto != null)
            {
                if (!headBytes.SequenceEqual(Header.HeadEncBegin))
                {
                    throw new NotAnOOFPackException();
                }
            }
            else
            {
                if (headBytes.SequenceEqual(Header.HeadEncBegin))
                {
                    throw new EncryptedException();
                }
                else if (!headBytes.SequenceEqual(Header.HeadBegin))
                {
                    throw new NotAnOOFPackException();
                }
            }

            HeadBytes  = ResolveHead(file, out int offset);
            Diff       = ResolveDiff(HeadBytes);
            BufferSize = ResolveBufferSize(HeadBytes);
            Files      = ResolveFiles(HeadBytes);

            DataPos = Header.HeadBegin.Length + sizeof(int) + offset;

            PacketAmount = Diff.Count;

            foreach (uint i in Diff)
            {
                TotalCompressRatio += ((BufferSize - i) / (BufferSize * (double)PacketAmount));
            }

            foreach (FileData f in Files)
            {
                TotalUncompressedSize += f.Length;
            }
        }
Esempio n. 2
0
        public FileUnpacker(string filePathtoUnpack, CryptoClass crypto, CancellationToken ct)
        {
            Token        = ct;
            filePath     = filePathtoUnpack;
            this.crypto  = crypto;
            inputStream  = new FileStream(filePathtoUnpack, FileMode.Open, FileAccess.Read);
            compressInfo = new CompressionInfo(inputStream, crypto);
            try
            {
                decompStream = new DecompressionStream(inputStream, compressInfo, crypto);
                decompStream.ReadByte();
                decompStream.Dispose();
            }
            catch (System.Security.Cryptography.CryptographicException)
            {
                inputStream.Dispose();
                throw new IncorrectKeyException();
            }

            fileDatas = compressInfo.Files;

            inputStream.Dispose();
        }
Esempio n. 3
0
 public FileBuilder(string[] inputFiles, uint BufferSize, CryptoClass crypto)
 {
     this.inputFiles = inputFiles;
     this.BufferSize = BufferSize;
     this.crypto     = crypto;
 }
Esempio n. 4
0
 public FileBuilder(string[] inputFiles, CryptoClass crypto) : this(inputFiles, 1048576, crypto)
 {
 }
Esempio n. 5
0
 public DecompressionStream(Stream toDecompressStream, CompressionInfo compressionInfo, CryptoClass crypto)
 {
     this.crypto = crypto;
     inputStream = toDecompressStream;
     ci          = compressionInfo;
     Position    = 0;
 }
Esempio n. 6
0
 public DecompressionStream(Stream toDecompressStream, CryptoClass crypto) : this(toDecompressStream, null, crypto)
 {
     ci = new CompressionInfo(toDecompressStream, null);
 }
Esempio n. 7
0
 public FileUnpacker(string filePathtoUnpack, CryptoClass crypto) : this(filePathtoUnpack, crypto, CancellationToken.None)
 {
 }