Esempio n. 1
0
        public static byte[] encodeHeaderData(LogMessage message)
        {
            var oldData = message.data;

            message.encodeData();

            string json = JsonConvert.SerializeObject(message);

            byte[] jsonBytes      = Encoding.ASCII.GetBytes(json);
            byte[] compressedJson = Compression.CompressLZMA(jsonBytes);
            byte[] encrypted      = Crypto.Encrypt(compressedJson, "password");
            int    messagelen     = encrypted.Length;

            byte[] messageHeader = BitConverter.GetBytes(messagelen);
            byte[] res           = messageHeader.Concat(encrypted).ToArray();
            message.data = oldData;

            return(res);
        }