public static byte[] SerializateMessage(string message, TlsManager tlsManager, RsaManager rsaManager) { byte[] IV, hashSum, digitalSignature, hashSumCount, messageBytes; string publicRSAKey = rsaManager.PublicKey; message = $"|rsaKeyStart|{publicRSAKey}|rsaKeyEnd|{message}"; messageBytes = tlsManager.EncryptMessage(message, out IV, out hashSum); hashSumCount = new byte[] { (byte)hashSum.Length }; digitalSignature = rsaManager.GetDigitalSignature(hashSum); return(IV.Concat(hashSumCount.Concat(hashSum.Concat(digitalSignature.Concat(messageBytes)))).ToArray()); }