def int_to_32bit_array(val):
    """Converts an integer to 32 bit bytearray

    :param val: the value to convert to bytes
    :type val: int
    :rtype: bytearray
    """
    value = val
    bytes = bytearray()
    for i in range(4):
        bytes.insert(0, value & 255)
        value >>= 8
    return str(bytes)
