예제 #1
0
        internal static byte[] CompressPRC(byte[] data, uint key, bool big_endian)
        {
            int dprs_size = data.Length;

            data = PRS.Compress(data);
            int cprs_size = data.Length;

            PRC prc = new PRC(key);

            Array.Resize(ref data, (int)((data.Length + 3) & 0xFFFFFFFC));
            prc.CryptData(data, 0, cprs_size, big_endian);

            ByteArray ba = new ByteArray(cprs_size + 8);

            if (big_endian)
            {
                ba.Endianess = Endianess.BigEndian;
            }

            ba.Write(dprs_size);
            ba.Write(key);
            ba.Write(data, 0, cprs_size);

            return(ba.Buffer);
        }
예제 #2
0
        internal static byte[] DecompressPRC(byte[] data, bool big_endian)
        {
            ByteArray ba = new ByteArray(data);

            if (big_endian)
            {
                ba.Endianess = Endianess.BigEndian;
            }

            int  size = ba.ReadI32();
            uint key  = ba.ReadU32();

            byte[] result = new byte[(int)((ba.Length - 8 + 3) & 0xFFFFFFFC)];
            ba.Read(result, 0, ba.Length - 8);

            PRC prc = new PRC(key);

            prc.CryptData(result, 0, result.Length, big_endian);
            Array.Resize(ref result, size);

            result = PRS.Decompress(result);

            return(result);
        }