Exemple #1
0
        private static byte[] Decrypt_Data(byte[] Data)
        {
            UInt16 Checksum = BitConverter.ToUInt16(Data, 0x6);

            UInt16   ucheck = Checksum;
            PokePRNG prng   = new PokePRNG();

            //(ucheck)
            prng.Seed = ucheck;

            for (int i = 8; i <= 135; i += 2)
            {
                ushort bef = BitConverter.ToUInt16(Data, i);
                ushort aft = (ushort)(bef ^ (prng.NextNum() >> 0x10));
                Data[i + 1] = (byte)(aft >> 0x8);
                Data[i]     = (byte)(aft & 0xff);
            }

            if (Data.Length == 136)
            {
                return(Data);
            }

            prng.Seed = BitConverter.ToUInt32(Data, 0);

            for (int i = 136; i <= 235; i += 2)
            {
                ushort bef = BitConverter.ToUInt16(Data, i);
                ushort aft = (ushort)(bef ^ (prng.NextNum() >> 0x10));
                Data[i + 1] = (byte)(aft >> 0x8);
                Data[i]     = (byte)(aft & 0xff);
            }

            return(Data);
        }
Exemple #2
0
        private static byte[] Decrypt_Data(byte[] Data)
        {
            UInt16 Checksum = BitConverter.ToUInt16(Data, 0x6);

            UInt16 ucheck = Checksum;
            PokePRNG prng = new PokePRNG();
            //(ucheck)
            prng.Seed = ucheck;

            for (int i = 8; i <= 135; i += 2)
            {
                ushort bef = BitConverter.ToUInt16(Data, i);
                ushort aft = (ushort)(bef ^ (prng.NextNum() >> 0x10));
                Data[i + 1] = (byte)(aft >> 0x8);
                Data[i] = (byte)(aft & 0xff);
            }

            if (Data.Length == 136) return Data;

            prng.Seed = BitConverter.ToUInt32(Data, 0);

            for (int i = 136; i <= 235; i += 2)
            {
                ushort bef = BitConverter.ToUInt16(Data, i);
                ushort aft = (ushort)(bef ^ (prng.NextNum() >> 0x10));
                Data[i + 1] = (byte)(aft >> 0x8);
                Data[i] = (byte)(aft & 0xff);
            }

            return Data;
        }