예제 #1
0
        public EgsHdAsset(Stream stream)
        {
            _stream     = stream;
            _baseOffset = stream.Position;

            _seed = stream.ReadBytes(0x10);
            _key  = EgsEncryption.GenerateKey(_seed, PASS_COUNT);

            _header = BinaryMapping.ReadObject <Header>(new MemoryStream(_seed));

            var entries = Enumerable
                          .Range(0, _header.RemasteredAssetCount)
                          .Select(_ => BinaryMapping.ReadObject <RemasteredEntry>(stream))
                          .ToList();

            _entries    = entries.ToDictionary(x => x.Name, x => x);
            _dataOffset = stream.Position;

            Assets = entries.Select(x => x.Name).ToArray();

            ReadData();

            foreach (var remasteredAssetName in Assets)
            {
                ReadRemasteredAsset(remasteredAssetName);
            }

            stream.SetPosition(_dataOffset);
        }
예제 #2
0
        public static byte[] Encrypt(byte[] data, byte[] seed)
        {
            const int PassCount = 10;
            var       key       = EgsEncryption.GenerateKey(seed, PassCount);

            for (var i = 0; i < Math.Min(data.Length, 0x100); i += 0x10)
            {
                EgsEncryption.EncryptChunk(key, data, i, PassCount);
            }

            return(data);
        }
예제 #3
0
        public EgsHdAsset(Stream stream)
        {
            _stream     = stream;
            _baseOffset = stream.Position;

            var seed = stream.ReadBytes(0x10);

            _key = EgsEncryption.GenerateKey(seed, PassCount);
            Key  = _key;

            _header = BinaryMapping.ReadObject <Header>(new MemoryStream(seed));

            var entries = Enumerable
                          .Range(0, _header.RemasteredAssetCount)
                          .Select(_ => BinaryMapping.ReadObject <RemasteredEntry>(stream))
                          .ToList();

            _entries    = entries.ToDictionary(x => x.Name, x => x);
            _dataOffset = stream.Position;

            Assets = entries.Select(x => x.Name).ToArray();
        }