public void SoftZipped1Test( ) { byte[] b1 = new byte[] { 0x13, 0xA6, 0x15, 0x85, 0x5B, 0x05, 0x12, 0x36, 0xF2, 0x27 }; byte[] b2 = SoftZipped.CompressBytes(b1); byte[] b3 = SoftZipped.Decompress(b2); Assert.IsTrue(SoftBasic.IsTwoBytesEquel(b1, b3)); }
/// <summary> /// 解析接收到数据,先解压缩后进行解密 /// </summary> /// <param name="head">指令头</param> /// <param name="content">指令的内容</param> /// <return>真实的数据内容</return> internal static byte[] CommandAnalysis(byte[] head, byte[] content) { if (content != null) { int _zipped = BitConverter.ToInt32(head, 8); // 先进行解压 if (_zipped == ProtocolZipped) { content = SoftZipped.Decompress(content); } // 进行解密 return(HslSecurity.ByteDecrypt(content)); } else { return(null); } }