我有一个脚本可以连接到我的工艺服务器、接收数据包并发送数据包。
所以,我发送一个“登录”数据包,我收到一个“登录”数据包。不幸的是,收到的登录数据包被编码(有关编码的信息在这里:http ://wiki.vg/Protocol#0x01 )。
接收到的登录数据包存储在一个名为 的变量中received_login_packet
。我需要对其进行解码,以便我可以获得单独的数据位,例如数据包类型,维度等......
我环顾四周,但我完全不知道如何去做。
如果有帮助,这里有一些代码:
#encoding the packet to send
encuserlen = str(len(enc_user)) # enc_user is just my username
packfmt = '>bih%sshiibBB' % encuserlen
packetbytes = struct.pack(packfmt, 1, 28, len(data['user']), enc_user, 0, 0, 0, 0, 0, 0)
s.send(packetbytes)
time.sleep(2)
#login packet sent, waited for response
response = s.recv(1024) #this is the raw login response.
#it's encoded as detailed above. i want to decode it
任何帮助将不胜感激,如果不够清楚,请不要犹豫。