示例#1
0
        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);
        }
示例#2
0
        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();
            }
        }