예제 #1
0
        //n zunifikowana zmiana stanu usera !!!!
        public byte[] CreateUnifiedUserDataMessageEncrypted(CscUserMainData userMainData, byte[] key)//CreateFriendUserDataMessage
        {
            var friendsAsBytes          = CscProtocol.Serialize(userMainData);
            var friendsAsBytesEncrypted = new CscAes(key).EncryptBytesToBytes(friendsAsBytes);
            var message = new byte[3 + friendsAsBytesEncrypted.Length];

            message[0] = 4;
            BitConverter.GetBytes((UInt16)friendsAsBytesEncrypted.Length).CopyTo(message, 1);
            friendsAsBytesEncrypted.CopyTo(message, 3);
            return(message);
        }
예제 #2
0
        //public CscUserData ReadUserData(byte[] message)
        //{
        //    var result = DeserializeWithLengthInfo(message) as CscUserData;

        //    if (result == null)
        //        throw new NullReferenceException();
        //    else
        //        return result;
        //}

        //user pasujacy do zapytania wyszukiwania userow
        public byte[] CreateSearchUserDataResponseEncrypted(CscUserMainData searchUserData, byte[] key)
        {
            var searchUserAsBytes          = CscProtocol.Serialize(searchUserData);
            var searchUserAsBytesEncrypted = new CscAes(key).EncryptBytesToBytes(searchUserAsBytes);
            var message = new byte[3 + searchUserAsBytesEncrypted.Length];

            message[0] = 3;
            BitConverter.GetBytes((UInt16)searchUserAsBytesEncrypted.Length).CopyTo(message, 1);
            searchUserAsBytesEncrypted.CopyTo(message, 3);
            return(message);
        }