All rays and light are essentially the same. When their energy is large enough, they can destroy matter, including living things. X-rays of a certain intensity can harm the human body, and gamma rays can kill cancer cells. This is the principle. Lasers with the highest energy density can destroy all matter. However, it consumes energy to maintain continuous light intensity, so people use pulses to emit light at regular intervals to kill bacteria.