summaryrefslogtreecommitdiffstats
path: root/sploit/arch.py
diff options
context:
space:
mode:
Diffstat (limited to 'sploit/arch.py')
-rw-r--r--sploit/arch.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/sploit/arch.py b/sploit/arch.py
index 36f48a4..5933a95 100644
--- a/sploit/arch.py
+++ b/sploit/arch.py
@@ -100,8 +100,14 @@ def uint64(i):
"""Convert given int to unsigned 64 bit int."""
return __int(i, False, 8)
-def btoi(b, signed=False):
- return int.from_bytes(b, arch.endianness, signed=signed)
+def btoi(b, byteorder=None):
+ """Convert given byte array to an int."""
+ byteorder = byteorder or arch.endianness
+ return int.from_bytes(b, byteorder, signed=False)
+
+def itob(i, width=None, byteorder=None):
+ """Convert given int to a byte array."""
+ width = width or arch.wordsize
+ byteorder = byteorder or arch.endianness
+ return __int(i,False,width).to_bytes(width, byteorder, signed=False)
-def itob(i, signed=False):
- return i.to_bytes(arch.wordsize, arch.endianness, signed=signed)