private Pack1Unarchiver(string packagePath, Pack1Meta metaData, string destinationDirPath, byte[] key, string suffix, BytesRange range)
        {
            Checks.ArgumentFileExists(packagePath, "packagePath");
            Checks.ArgumentDirectoryExists(destinationDirPath, "destinationDirPath");
            Checks.ArgumentNotNull(suffix, "suffix");

            if (range.Start == 0)
            {
                Assert.AreEqual(MagicBytes.Pack1, MagicBytes.ReadFileType(packagePath), "Is not Pack1 format");
            }

            DebugLogger.LogConstructor();
            DebugLogger.LogVariable(packagePath, "packagePath");
            DebugLogger.LogVariable(destinationDirPath, "destinationDirPath");
            DebugLogger.LogVariable(suffix, "suffix");

            _packagePath        = packagePath;
            _metaData           = metaData;
            _destinationDirPath = destinationDirPath;
            _suffix             = suffix;
            _range = range;

            using (var sha256 = SHA256.Create())
            {
                _key = sha256.ComputeHash(key);
            }

            _iv = Convert.FromBase64String(_metaData.Iv);
        }
        private DecompressorCreator ResolveDecompressor(Pack1Meta meta)
        {
            switch (meta.Compression)
            {
            case Pack1Meta.XZCompression:
                return(CreateXzDecompressor);

            case Pack1Meta.GZipCompression:
                return(CreateGzipDecompressor);

            default:
                return(CreateGzipDecompressor);
            }
        }
Ejemplo n.º 3
0
        public Pack1Unarchiver(string packagePath, Pack1Meta metaData, string destinationDirPath, byte[] key)
        {
            Checks.ArgumentFileExists(packagePath, "packagePath");
            Checks.ArgumentDirectoryExists(destinationDirPath, "destinationDirPath");
            Assert.AreEqual(MagicBytes.Pack1, MagicBytes.ReadFileType(packagePath), "Is not Pack1 format");

            DebugLogger.LogConstructor();
            DebugLogger.LogVariable(packagePath, "packagePath");
            DebugLogger.LogVariable(destinationDirPath, "destinationDirPath");

            _packagePath        = packagePath;
            _metaData           = metaData;
            _destinationDirPath = destinationDirPath;

            using (var sha256 = SHA256.Create())
            {
                _key = sha256.ComputeHash(key);
            }

            _iv = Convert.FromBase64String(_metaData.Iv);
        }
Ejemplo n.º 4
0
 public Pack1Unarchiver(string packagePath, Pack1Meta metaData, string destinationDirPath, string key)
     : this(packagePath, metaData, destinationDirPath, Encoding.ASCII.GetBytes(key))
 {
     // do nothing
 }
 public Pack1Unarchiver(string packagePath, Pack1Meta metaData, string destinationDirPath, string key, string suffix = "")
     : this(packagePath, metaData, destinationDirPath, Encoding.ASCII.GetBytes(key), suffix, new BytesRange(0, -1))
 {
     // do nothing
 }