Skip to content

Commit

Permalink
Merge pull request #3 from jaicis/py3convert
Browse files Browse the repository at this point in the history
python forward porting
  • Loading branch information
jaicis committed Oct 18, 2019
2 parents fad7f3a + 95990d8 commit 8fa0121
Show file tree
Hide file tree
Showing 57 changed files with 355 additions and 448 deletions.
10 changes: 5 additions & 5 deletions src/addresses.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def encodeAddress(version, stream, ripe):
raise Exception(
'Programming error in encodeAddress: The length of'
' a given ripe hash was not 20.')
ripe = ripe.lstrip('\x00')
ripe = ripe.lstrip('\x00'.encode('utf-8'))

storedBinaryData = encodeVarint(version) + encodeVarint(stream) + ripe

Expand All @@ -180,7 +180,6 @@ def decodeAddress(address):
data (almost certainly a ripe hash))
"""
# pylint: disable=too-many-return-statements,too-many-statements,too-many-return-statements,too-many-branches

address = str(address).strip()

if address[:3] == 'BM-':
Expand All @@ -192,7 +191,7 @@ def decodeAddress(address):
return status, 0, 0, ''
# after converting to hex, the string will be prepended
# with a 0x and appended with a L
hexdata = hex(integer)[2:-1]
hexdata = hex(integer)[2:]

if len(hexdata) % 2 != 0:
hexdata = '0' + hexdata
Expand Down Expand Up @@ -248,7 +247,7 @@ def decodeAddress(address):
embeddedRipeData
elif len(embeddedRipeData) == 18:
return status, addressVersionNumber, streamNumber, \
'\x00\x00' + embeddedRipeData
'\x00\x00'.encode('utf-8') + embeddedRipeData
elif len(embeddedRipeData) < 18:
return 'ripetooshort', 0, 0, ''
elif len(embeddedRipeData) > 20:
Expand All @@ -265,7 +264,8 @@ def decodeAddress(address):
return 'ripetoolong', 0, 0, ''
elif len(embeddedRipeData) < 4:
return 'ripetooshort', 0, 0, ''
x00string = '\x00' * (20 - len(embeddedRipeData))
x00string = '\x00'.encode('utf-8') * (20 - len(embeddedRipeData))

return status, addressVersionNumber, streamNumber, \
x00string + embeddedRipeData

Expand Down
4 changes: 2 additions & 2 deletions src/bitmessagekivy/identiconGeneration.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ def generate_hash(string):
# make input case insensitive
string = str.lower(string)
hash_object = hashlib.md5(str.encode(string))
print hash_object.hexdigest()
print(hash_object.hexdigest())

# returned object is a hex string
return hash_object.hexdigest()

except IndexError:
print "Error: Please enter a string as an argument."
print("Error: Please enter a string as an argument.")


def random_color(hash_string):
Expand Down
Loading

0 comments on commit 8fa0121

Please sign in to comment.