Exemple #1
0
        public void Clear()
        {
            mItemDict.Clear();
            mDirSet.Clear();
            mFileList = new FileList
            {
                CurVersion = PublishTarget.Current.ClientVersion.ToProtoVersion()
            };

            mFileId = 0;

            mCoders.Clear();
            mProtoCoders.Clear();
            if (PublishTarget.Current.IsCompress)
            {
                mCoders.Add(new LZMAEncoder(null));
                LZMADecoder decoder = new LZMADecoder(null);
                mProtoCoders.Add(decoder.CoderInfo);
            }

            if (PublishTarget.Current.IsEncrypt)
            {
                const string key = "{803CE8F2-8C0E-4159-96CB-921D89C08E13}{2519C077-1247-4AF5-8C71-C7367A481C2D}{975C6505-5494-4A36-9AD6-B4890B0E2F79}{B0DC6B72-83CC-4E81-8566-AD3AC306FE3A}{4B75FE65-1ADC-47AC-890A-293AD2A1968D}";

                var bytes    = Encoding.UTF8.GetBytes(key);
                var keyBytes = BaseCoder.ByteArrayToString(bytes);
                mCoders.Add(new XOREncoder(bytes));

                XORDecoder decoder = new XORDecoder(null);
                mProtoCoders.Add(decoder.CoderInfo);
            }

            mProtoCoders.Reverse();
        }
Exemple #2
0
        public static byte[] Decompress(Stream input, int outputLength)
        {
            var decoder = new LZMADecoder();

            using (var output = new MemoryStream(outputLength))
            {
                input.Position += 4;
                var lzmaProperties = new byte[5];
                input.Read(lzmaProperties, 0, 5);

                decoder.SetDecoderProperties(lzmaProperties);
                decoder.Code(input, output, input.Length, outputLength, null);
                return(output.ToArray());
            }
        }
Exemple #3
0
        public static byte[] DecompressBuffer(byte[] data, int bufferSize)
        {
            var lzmaDecoder = new LZMADecoder();
            using (var inStream = new MemoryStream(data))
            using (var outStream = new MemoryStream(bufferSize))
            {
                inStream.Position += 4;

                var lzmaProperties = new byte[5];
                inStream.Read(lzmaProperties, 0, 5);

                lzmaDecoder.SetDecoderProperties(lzmaProperties);
                lzmaDecoder.Code(inStream, outStream, inStream.Length, bufferSize, null);
                return outStream.ToArray();
            }
        }
Exemple #4
0
        public static byte[] DecompressBuffer(byte[] data, int bufferSize)
        {
            var lzmaDecoder = new LZMADecoder();

            using (var inStream = new MemoryStream(data))
                using (var outStream = new MemoryStream(bufferSize))
                {
                    inStream.Position += 4;

                    var lzmaProperties = new byte[5];
                    inStream.Read(lzmaProperties, 0, 5);

                    lzmaDecoder.SetDecoderProperties(lzmaProperties);
                    lzmaDecoder.Code(inStream, outStream, inStream.Length, bufferSize, null);
                    return(outStream.ToArray());
                }
        }