def int_to_32bit_array(val):
    """
    Converts an integer to 32 bit bytearray
    :param val: the value to convert to bytes
    :return: bytearray
    """
    value = val
    bytes = bytearray()
    for i in range(4):
        bytes.insert(0, (value & 0xff))
        value >>= 8
    return str(bytes)