scrachy.utils.numeric.slice_int

scrachy.utils.numeric.slice_int(bt: bytes, nbits: int) int[source]

Take the first nbits of bt and convert that into an integer.

From: https://stackoverflow.com/a/47086786/4971706

Parameters:
  • bt – The bytes of arbitrary length.

  • nbits – The number of bits to keep.

Returns:

The resulting integer.