In trying to search for a Japanese equivalent to "I hope~" in English, I've found two expressions 「といいね」and「ように(祈る/願う)」. However, I'm not sure how to use them properly. (I feel that the latter construction is more similar to "I hope" purely in terms of structure, but that doesn't mean anything, necessarily.) What is the difference between these two expressions?
For example, what's the difference between
(1) 試験に合格するように
(2) 試験に合格するといいな
in trying to say "I hope you pass the exam"?