Ejemplo n.º 1
0
        public static bool UnPackMiniData(byte[] packBuf, out MMPKG_mini_header miniHeader, out byte[] cipherText)
        {
            cipherText = null;
            if (PackMini.mmpkg_mini_head_ntoh(packBuf, out miniHeader) != 0)
            {
                Log.e("MMPack", " UnPack failed: invlaide args");
                return(false);
            }
            int len   = miniHeader.len;
            int count = packBuf.Length - miniHeader.len;

            cipherText = new byte[count];
            Buffer.BlockCopy(packBuf, len, cipherText, 0, count);
            return(true);
        }
Ejemplo n.º 2
0
        private static bool useMiniUnPack(byte[] packBuf)
        {
            MMPKG_mini_header _header;
            int num = PackMini.mmpkg_mini_head_ntoh(packBuf, out _header);

            if (num != 0)
            {
                Log.d("MMPack", "not UseMiniUnPack, ret = " + num);
                return(false);
            }
            if (_header.len >= 0x2f)
            {
                Log.d("MMPack", "not UseMiniUnPack, packBuf[0] = " + packBuf[0]);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 3
0
        private static bool PackMiniData(out byte[] packBuf, MMPKG_mini_header miniHeader, byte[] data)
        {
            packBuf = null;
            byte[] outbuff = null;

            int num = PackMini.mmpkg_mini_head_hton(miniHeader, out outbuff);

            //string aa = Util.byteToHexStr(outbuff);
            if (num != 0)
            {
                Log.e("MMPack", "mmpkg_mini_head_hton failed, ret = " + num);
                return(false);
            }
            int length = outbuff.Length;
            int num3   = data.Length;

            packBuf = new byte[length + num3];
            int dstOffset = 0;

            Buffer.BlockCopy(outbuff, 0, packBuf, dstOffset, outbuff.Length);
            dstOffset += outbuff.Length;
            Buffer.BlockCopy(data, 0, packBuf, dstOffset, data.Length);
            return(true);
        }