def METHOD_NAME(payload: bytes,
                       msg_or_data_id: Union[int, Message]) \
  -> Optional[bytearray]:
    """Compute the AUTOSAR E2E checksum for profile 5 of the AUTOSAR
    end-to-end protection specification and apply it to an encoded
    payload.
    If the message is passed, this function also takes care of special
    cases like the message not being end-to-end protected or being a
    secured frame.
    """
    crc = compute_profile5_crc(payload, msg_or_data_id)
    if crc is None:
        return None
    result = bytearray(payload)
    result[0] = crc&0xff
    result[1] = (crc>>8)&0xff
    return result