diff options
Diffstat (limited to 'gotr/potr/utils.py')
-rw-r--r-- | gotr/potr/utils.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/gotr/potr/utils.py b/gotr/potr/utils.py index 2bedf55..e41ca46 100644 --- a/gotr/potr/utils.py +++ b/gotr/potr/utils.py @@ -43,11 +43,12 @@ def bytes_to_long(b): s += byte_to_long(b[i:i+1]) << 8*(l-i-1) return s -def long_to_bytes(l): +def long_to_bytes(l, n=0): b = b'' - while l != 0: + while l != 0 or n > 0: b = long_to_byte(l & 0xff) + b l >>= 8 + n -= 1 return b def byte_to_long(b): |