mirror of
https://github.com/ammaraskar/pyCraft.git
synced 2025-01-08 17:08:21 +01:00
Fix hexdigest
This commit is contained in:
parent
f18c6496b8
commit
71ca5f2952
21
Utils.py
21
Utils.py
@ -3,14 +3,15 @@ import array
|
|||||||
def stringToByteArray(string):
|
def stringToByteArray(string):
|
||||||
return array.array('B', string.decode("hex"))
|
return array.array('B', string.decode("hex"))
|
||||||
|
|
||||||
def TwosCompliment(hash):
|
def TwosCompliment(digest):
|
||||||
hash = array.array('B', hash.decode("hex"))
|
|
||||||
carry = True
|
carry = True
|
||||||
for i in range((hash.__len__() - 1), 0, -1):
|
for i in range((digest.__len__() - 1), -1, -1):
|
||||||
|
value = 255 - digest[i]
|
||||||
|
digest[i] = value
|
||||||
if(carry):
|
if(carry):
|
||||||
carry = hash[i] == 0xFF
|
carry = digest[i] == 0xFF
|
||||||
hash[i] += 1
|
digest[i] = digest[i] + 1
|
||||||
return hash
|
return digest
|
||||||
|
|
||||||
def trimStart(string, character):
|
def trimStart(string, character):
|
||||||
for c in string:
|
for c in string:
|
||||||
@ -20,3 +21,11 @@ def trimStart(string, character):
|
|||||||
break
|
break
|
||||||
return string
|
return string
|
||||||
|
|
||||||
|
def getHexString(byteArray):
|
||||||
|
result = ""
|
||||||
|
for i in range(byteArray.__len__()):
|
||||||
|
if (byteArray[i] < 0x10):
|
||||||
|
result += '0'
|
||||||
|
result += hex(byteArray[i])[2:]
|
||||||
|
return result
|
||||||
|
|
@ -94,7 +94,6 @@ class ServerConnection(threading.Thread):
|
|||||||
try:
|
try:
|
||||||
#Open up the url with the appropriate get parameters
|
#Open up the url with the appropriate get parameters
|
||||||
url = "http://session.minecraft.net/game/joinserver.jsp?user=" + self.username + "&sessionId=" + self.sessionID + "&serverId=" + serverid
|
url = "http://session.minecraft.net/game/joinserver.jsp?user=" + self.username + "&sessionId=" + self.sessionID + "&serverId=" + serverid
|
||||||
print url
|
|
||||||
response = urllib2.urlopen(url).read()
|
response = urllib2.urlopen(url).read()
|
||||||
|
|
||||||
if(response != "OK"):
|
if(response != "OK"):
|
||||||
@ -306,7 +305,7 @@ class PacketListener(threading.Thread):
|
|||||||
elif(response == "\x67"):
|
elif(response == "\x67"):
|
||||||
PacketListenerManager.handle67(self.FileObject)
|
PacketListenerManager.handle67(self.FileObject)
|
||||||
elif(response == "\x68"):
|
elif(response == "\x68"):
|
||||||
print PacketListenerManager.handle68(self.FileObject)
|
PacketListenerManager.handle68(self.FileObject)
|
||||||
elif(response == "\x69"):
|
elif(response == "\x69"):
|
||||||
PacketListenerManager.handle69(self.FileObject)
|
PacketListenerManager.handle69(self.FileObject)
|
||||||
elif(response == "\x6A"):
|
elif(response == "\x6A"):
|
||||||
@ -322,7 +321,7 @@ class PacketListener(threading.Thread):
|
|||||||
elif(response == "\xC8"):
|
elif(response == "\xC8"):
|
||||||
PacketListenerManager.handleC8(self.FileObject)
|
PacketListenerManager.handleC8(self.FileObject)
|
||||||
elif(response == "\xC9"):
|
elif(response == "\xC9"):
|
||||||
print PacketListenerManager.handleC9(self.FileObject)
|
PacketListenerManager.handleC9(self.FileObject)
|
||||||
elif(response == "\xCA"):
|
elif(response == "\xCA"):
|
||||||
PacketListenerManager.handleCA(self.FileObject)
|
PacketListenerManager.handleCA(self.FileObject)
|
||||||
elif(response == "\xCB"):
|
elif(response == "\xCB"):
|
||||||
|
Loading…
Reference in New Issue
Block a user