Utils

riemann.utils.be2i(b: bytes, signed: bool = False) → int

Convert big endian (b.e.) bytes to int

Parameters
  • b – BE bytes to convert to int

  • signed – two’s complement flag

Returns:

riemann.utils.blake256(msg_bytes: bytes) → bytes

blake256 digest of a message

riemann.utils.blake2b(data: bytes = b'', **kwargs) → bytes

blake2b digest of a message

riemann.utils.blake2s(data: bytes = b'', **kwargs) → bytes

blake2s digest of a message

riemann.utils.change_endianness(b: bytes) → bytes

Reverse a bytestring

riemann.utils.hash160(msg_bytes: bytes) → bytes

rmd160 of sha256 of message

riemann.utils.hash256(msg_bytes: bytes) → bytes

sha256 of sha256 of message

riemann.utils.i2be(number: int) → bytes

Convert int to big endian (b.e.) bytes

Parameters

number – int value to convert to bytes in BE format

Returns

bytes in BE format

riemann.utils.i2be_padded(number: int, length: int) → bytes

Convert int to big endian (b.e.) bytes with specified length

Parameters
  • number – int value to convert to bytes in BE format

  • length – length of resulting bytes

Returns

bytes in BE format with specified length

riemann.utils.i2le(number: int) → bytes

Convert int to little endian (LE) bytes

Parameters

number – int value to convert to bytes in LE format

Returns

LE-encoded number

riemann.utils.i2le_padded(number: int, length: int) → bytes

Convert int to little endian (LE) bytes with specified length

Parameters
  • number – int value to convert to LE bytes

  • length – length of resulting bytes

Returns

LE-encoded number with fixed length

riemann.utils.i2le_script(number: int) → str

Convert int to signed little endian (LE) hex for use within scripts

Parameters

number – int value to convert to bytes in LE format

Returns

the hex-encoded signed LE number

riemann.utils.le2i(b: bytes, signed: bool = False) → int

Convert little endian (LE) bytes to int

Parameters
  • b – LE bytes to convert to int

  • signed – two’s complement flag

Returns:

riemann.utils.rmd160(msg_bytes: bytes) → bytes

ripemd160 digest of a messge

riemann.utils.sha256(msg_bytes: bytes) → bytes

sha256 digest of a message