These mantras are effective in times of danger, but also for remembrance (dhikr) of الله Allah (may He be praised and exalted). Such mantras are defensive in nature, but can also help you penetrate, within contemplation (mushahadah), the nature of a dream or vision.
For thirty years I sought God. But when I looked carefully I found that in reality God was the seeker and I the sought. -Bayazid al-Bastami