public SecondRankConnectionRequestMessage(byte[] data, IAsymmetricKey networkKey) { this.networkKey = networkKey; var rawReader = new BigEndianBinaryReader(new MemoryStream(data)); SymmetricKeyBytes = AsymmetricHelper.Decrypt(this.networkKey, rawReader.ReadBytes(rawReader.ReadUInt16())); }
public byte[] GetBytes() { var memoryStream = new MemoryStream(); var writer = new BigEndianBinaryWriter(memoryStream); var encryptedSymmetricKey = AsymmetricHelper.Encrypt(networkKey, SymmetricKeyBytes); writer.Write((ushort)encryptedSymmetricKey.Length); writer.Write(encryptedSymmetricKey); return(memoryStream.ToArray()); }