def auth_ok(self, data): """ Called if the Mojang session server responds to our query. Note that this method does not indicate that the server accepted our session; in this case :meth:`player_joined` is called. """ # Send encryption response p_shared_secret = crypto.encrypt_secret( self.public_key, self.shared_secret) p_verify_token = crypto.encrypt_secret( self.public_key, self.verify_token) # 1.7.x if self.protocol_version <= 5: pack_array = lambda d: self.buff_type.pack('h', len(d)) + d # 1.8.x else: pack_array = lambda d: self.buff_type.pack_varint( len(d), max_bits=16) + d self.send_packet( "login_encryption_response", pack_array(p_shared_secret) + pack_array(p_verify_token)) # Enable encryption self.cipher.enable(self.shared_secret) self.logger.debug("Encryption enabled")