mirror of
https://github.com/ammaraskar/pyCraft.git
synced 2025-01-06 07:58:17 +01:00
Fix hexdigest
This commit is contained in:
parent
f18c6496b8
commit
71ca5f2952
23
Utils.py
23
Utils.py
@ -3,14 +3,15 @@ import array
|
||||
def stringToByteArray(string):
|
||||
return array.array('B', string.decode("hex"))
|
||||
|
||||
def TwosCompliment(hash):
|
||||
hash = array.array('B', hash.decode("hex"))
|
||||
def TwosCompliment(digest):
|
||||
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):
|
||||
carry = hash[i] == 0xFF
|
||||
hash[i] += 1
|
||||
return hash
|
||||
carry = digest[i] == 0xFF
|
||||
digest[i] = digest[i] + 1
|
||||
return digest
|
||||
|
||||
def trimStart(string, character):
|
||||
for c in string:
|
||||
@ -19,4 +20,12 @@ def trimStart(string, character):
|
||||
else:
|
||||
break
|
||||
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:
|
||||
#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
|
||||
print url
|
||||
response = urllib2.urlopen(url).read()
|
||||
|
||||
if(response != "OK"):
|
||||
@ -306,7 +305,7 @@ class PacketListener(threading.Thread):
|
||||
elif(response == "\x67"):
|
||||
PacketListenerManager.handle67(self.FileObject)
|
||||
elif(response == "\x68"):
|
||||
print PacketListenerManager.handle68(self.FileObject)
|
||||
PacketListenerManager.handle68(self.FileObject)
|
||||
elif(response == "\x69"):
|
||||
PacketListenerManager.handle69(self.FileObject)
|
||||
elif(response == "\x6A"):
|
||||
@ -322,7 +321,7 @@ class PacketListener(threading.Thread):
|
||||
elif(response == "\xC8"):
|
||||
PacketListenerManager.handleC8(self.FileObject)
|
||||
elif(response == "\xC9"):
|
||||
print PacketListenerManager.handleC9(self.FileObject)
|
||||
PacketListenerManager.handleC9(self.FileObject)
|
||||
elif(response == "\xCA"):
|
||||
PacketListenerManager.handleCA(self.FileObject)
|
||||
elif(response == "\xCB"):
|
||||
|
Loading…
Reference in New Issue
Block a user