Ejemplo 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;
            }
        }
Ejemplo 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();
        }
Ejemplo n.º 3
0
 public FileBuilder(string[] inputFiles, uint BufferSize, CryptoClass crypto)
 {
     this.inputFiles = inputFiles;
     this.BufferSize = BufferSize;
     this.crypto     = crypto;
 }
Ejemplo n.º 4
0
 public FileBuilder(string[] inputFiles, CryptoClass crypto) : this(inputFiles, 1048576, crypto)
 {
 }
Ejemplo n.º 5
0
 public DecompressionStream(Stream toDecompressStream, CompressionInfo compressionInfo, CryptoClass crypto)
 {
     this.crypto = crypto;
     inputStream = toDecompressStream;
     ci          = compressionInfo;
     Position    = 0;
 }
Ejemplo n.º 6
0
 public DecompressionStream(Stream toDecompressStream, CryptoClass crypto) : this(toDecompressStream, null, crypto)
 {
     ci = new CompressionInfo(toDecompressStream, null);
 }
Ejemplo n.º 7
0
 public FileUnpacker(string filePathtoUnpack, CryptoClass crypto) : this(filePathtoUnpack, crypto, CancellationToken.None)
 {
 }