private BaseMessage GetMessageFromInput(string input) { var AESIV = GetIVFromInput(input); var encryptedMessage = GetEncryptedMessageFromInput(input); var decryptedMessage = AESWrapper.DecryptStringFromBytes(encryptedMessage, AESKey, AESIV); var baseMessage = BaseMessage.Deserialize(decryptedMessage); return(baseMessage); }
private Login GetLoginMessage(StreamReader reader, byte[] AESKey) { string input = reader.ReadLine(); var AESIV = GetIVFromInput(input); var encryptedMessage = GetEncryptedMessageFromInput(input); var decryptedMessage = AESWrapper.DecryptStringFromBytes(encryptedMessage, AESKey, AESIV); var baseMessage = BaseMessage.Deserialize(decryptedMessage); if (baseMessage.Type == MessageType.Login) { return(Login.Deserialize(baseMessage)); } else { throw new InvalidOperationException(); } }