From 6d5127c89a4ed2e1e3dccc8fd813b065d3c8784f Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Wed, 16 Aug 2017 17:20:26 +0200 Subject: [PATCH] add list_to_int() utility function to convert byte-lists to integers --- utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/utils.py b/utils.py index 9d0dbcd..c2d76f1 100644 --- a/utils.py +++ b/utils.py @@ -65,3 +65,7 @@ def swap_nibbles(array): for a in array: rc.append(((a & 0xf0) >> 4) | ((a & 0x0f) << 4)) return rc + +# Convert from list of bytes to big-endian integer +def list_to_int(arr): + return int(hexdump(arr), 16)