// Token: 0x06000148 RID: 328 RVA: 0x00008D60 File Offset: 0x00006F60 private byte[] BuildPacket(byte[] payload) { payload = SafeQuickLZ.Compress(payload, 3); payload = GClass18.smethod_3(payload); byte[] array = new byte[payload.Length + this.HEADER_SIZE]; Array.Copy(BitConverter.GetBytes(payload.Length), array, this.HEADER_SIZE); Array.Copy(payload, 0, array, this.HEADER_SIZE, payload.Length); return(array); }
public void SmallDataCompressionTestLevel1() { byte[] smallData = new byte[100]; new Random().NextBytes(smallData); byte[] smallDataCompressed = SafeQuickLZ.Compress(smallData, 1); Assert.AreNotEqual(smallData, smallDataCompressed, "Original data is equal to the compressed data!"); byte[] smallDataDecompressed = SafeQuickLZ.Decompress(smallDataCompressed); Assert.AreNotEqual(smallDataCompressed, smallDataDecompressed, "Compressed data is equal to the decompressed data!"); CollectionAssert.AreEqual(smallData, smallDataDecompressed, "Original data does not match the decompressed data!"); }
private byte[] BuildMessage(byte[] payload) { if (compressionEnabled) { payload = SafeQuickLZ.Compress(payload); } byte[] message = new byte[payload.Length + HEADER_SIZE]; Array.Copy(BitConverter.GetBytes(payload.Length), message, HEADER_SIZE); Array.Copy(payload, 0, message, HEADER_SIZE, payload.Length); return(message); }
private byte[] BuildPacket(byte[] payload) { if (compressionEnabled) payload = SafeQuickLZ.Compress(payload); if (encryptionEnabled) payload = AES.Encrypt(payload); byte[] packet = new byte[payload.Length + _parentServer.HEADER_SIZE]; Array.Copy(BitConverter.GetBytes(payload.Length), packet, _parentServer.HEADER_SIZE); Array.Copy(payload, 0, packet, _parentServer.HEADER_SIZE, payload.Length); return packet; }
public void BigDataCompressionTestLevel3() { var bigData = new byte[100000]; new Random().NextBytes(bigData); var bigDataCompressed = SafeQuickLZ.Compress(bigData, 3); Assert.AreNotEqual(bigData, bigDataCompressed, "Original data is equal to the compressed data!"); var bigDataDecompressed = SafeQuickLZ.Decompress(bigDataCompressed); Assert.AreNotEqual(bigDataCompressed, bigDataDecompressed, "Compressed data is equal to the decompressed data!"); CollectionAssert.AreEqual(bigData, bigDataDecompressed, "Original data does not match the decompressed data!"); }
private byte[] BuildMessage(byte[] payload) { if (compressionEnabled) { payload = SafeQuickLZ.Compress(payload); } if (encryptionEnabled) { payload = Aes128.Encrypt(payload); } byte[] message = new byte[payload.Length + _parentServer.HEADER_SIZE]; Array.Copy(BitConverter.GetBytes(payload.Length), message, _parentServer.HEADER_SIZE); Array.Copy(payload, 0, message, _parentServer.HEADER_SIZE, payload.Length); return(message); }
public void BigDataCompressionTestLevel3() { byte[] bigData = new byte[100000]; // Fill the big data array with random data. new Random().NextBytes(bigData); // Store the compressed data. byte[] bigDataCompressed = SafeQuickLZ.Compress(bigData, 3); // The original should not equal the compressed data. Assert.AreNotEqual(bigData, bigDataCompressed, "Original data is equal to the compressed data!"); // Store the decompressed data. byte[] bigDataDecompressed = SafeQuickLZ.Decompress(bigDataCompressed); // The compressed data should not equal the decompressed data. Assert.AreNotEqual(bigDataCompressed, bigDataDecompressed, "Compressed data is equal to the decompressed data!"); // The original data must equal the decompressed data; must be able to make a round-trip. CollectionAssert.AreEqual(bigData, bigDataDecompressed, "Original data does not match the decompressed data!"); }
public void SmallDataCompressionTestLevel3() { byte[] smallData = new byte[100]; // Fill the small data array with random data. new Random().NextBytes(smallData); // Store the compressed data. byte[] smallDataCompressed = SafeQuickLZ.Compress(smallData, 3); // The original should not equal the compressed data. Assert.AreNotEqual(smallData, smallDataCompressed); // Store the decompressed data. byte[] smallDataDecompressed = SafeQuickLZ.Decompress(smallDataCompressed); // The compressed data should not equal the decompressed data. Assert.AreNotEqual(smallDataCompressed, smallDataDecompressed); // The original data must equal the decompressed data; must be able to make a round-trip. CollectionAssert.AreEqual(smallData, smallDataDecompressed); }
public void SmallDataCompressionTestLevel3() { SafeQuickLZ safeQuickLZtest = new SafeQuickLZ(); byte[] smallData = new byte[100]; // Fill the small data array with random data. new Random().NextBytes(smallData); // Store the compressed data. byte[] smallDataCompressed = safeQuickLZtest.Compress(smallData, 0, smallData.Length, 3); // The original should not equal the compressed data. Assert.AreNotEqual(smallData, smallDataCompressed, "Original data is equal to the compressed data!"); // Store the decompressed data. byte[] smallDataDecompressed = safeQuickLZtest.Decompress(smallDataCompressed, 0, smallDataCompressed.Length); // The compressed data should not equal the decompressed data. Assert.AreNotEqual(smallDataCompressed, smallDataDecompressed, "Compressed data is equal to the decompressed data!"); // The original data must equal the decompressed data; must be able to make a round-trip. CollectionAssert.AreEqual(smallData, smallDataDecompressed, "Original data does not match the decompressed data!"); }
private byte[] BuildPacket(byte[] payload) { try { if (compressionEnabled) { payload = SafeQuickLZ.Compress(payload); } if (encryptionEnabled) { payload = AES.Encrypt(payload); } byte[] packet = new byte[payload.Length + HEADER_SIZE]; Array.Copy(BitConverter.GetBytes(payload.Length), packet, HEADER_SIZE); Array.Copy(payload, 0, packet, HEADER_SIZE, payload.Length); return(packet); } catch (Exception ex) { Debug.WriteLine($@"{ex.Message}\n{ex.StackTrace}\n{ex.Source}"); } return(null); }
private byte[] BuildMessage(byte[] payload) { int uncompressedSize = payload.Length; // 1300 if (compressionEnabled) { payload = SafeQuickLZ.Compress(payload); } int compressedSize = payload.Length; // 1000 double ratio = (double)uncompressedSize / compressedSize - 1; System.Diagnostics.Debug.WriteLine($"Send ratio: {ratio}"); if (encryptionEnabled) { payload = AES.Encrypt(payload); } byte[] message = new byte[payload.Length + _parentServer.HEADER_SIZE]; Array.Copy(BitConverter.GetBytes(payload.Length), message, _parentServer.HEADER_SIZE); Array.Copy(payload, 0, message, _parentServer.HEADER_SIZE, payload.Length); return(message); }