mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
byte2int for PY3
This commit is contained in:
parent
8b7a37a196
commit
32f1d35c93
2 changed files with 8 additions and 1 deletions
|
@ -67,7 +67,7 @@ class Journal(object):
|
||||||
util.prompt("ERROR: Your journal file seems to be corrupted. You do have a backup, don't you?")
|
util.prompt("ERROR: Your journal file seems to be corrupted. You do have a backup, don't you?")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
padding_length = ord(plain[-1])
|
padding_length = util.byte2int(plain[-1])
|
||||||
if padding_length > AES.block_size and padding_length != 32:
|
if padding_length > AES.block_size and padding_length != 32:
|
||||||
# 32 is the space character and is kept for backwards compatibility
|
# 32 is the space character and is kept for backwards compatibility
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -145,3 +145,10 @@ def int2byte(i):
|
||||||
"""Converts an integer to a byte.
|
"""Converts an integer to a byte.
|
||||||
This is equivalent to chr() in Python 2 and bytes((i,)) in Python 3."""
|
This is equivalent to chr() in Python 2 and bytes((i,)) in Python 3."""
|
||||||
return chr(i) if PY2 else bytes((i,))
|
return chr(i) if PY2 else bytes((i,))
|
||||||
|
|
||||||
|
|
||||||
|
def byte2int(b):
|
||||||
|
"""Converts a byte to an integer.
|
||||||
|
This is equivalent to ord(bs[0]) on Python 2 and bs[0] on Python 3."""
|
||||||
|
return ord(b)if PY2 else b
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue