def int_to_bytes(integer):
    """
    Convert an int to bytes
    :param integer:
    :return: bytes
    """
    return integer.to_bytes((integer.bit_length() + 7) // 8, 'big')
    # alternatively
    # return bytes.fromhex(hex(integer)[2:])