Fix hexdigest

This commit is contained in:
Ammar Askar committed 2012-09-06 15:08:03 +05:00
1 parent f18c6496b8
commit 71ca5f2952
2 files changed
+18 -10

No files matched your search

+16 -7
View File
@@ -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