encoding.py 199 B

123456
  1. def int_to_big_endian(value: int) -> bytes:
  2. return value.to_bytes((value.bit_length() + 7) // 8 or 1, "big")
  3. def big_endian_to_int(value: bytes) -> int:
  4. return int.from_bytes(value, "big")