Example #1
0
        byte[] DecryptIndex(ArcView idx)
        {
            int idx_size = (int)idx.MaxOffset - 4;

            byte[] output = new byte[idx_size];
            using (var view = idx.CreateViewAccessor(0, (uint)idx.MaxOffset))
                unsafe
                {
                    var rng = new CRuntimeRandomGenerator();
                    rng.SRand(view.ReadInt32(idx_size));
                    byte *ptr = view.GetPointer(0);
                    try
                    {
                        for (int i = 0; i < idx_size; ++i)
                        {
                            output[i] = (byte)(ptr[i] ^ IndexKey[rng.Rand() % IndexKey.Length]);
                        }
                        return(output);
                    }
                    finally
                    {
                        view.SafeMemoryMappedViewHandle.ReleasePointer();
                    }
                }
        }