Writing software that is secure and ideally secure by design is no easy task. It is well worth taking the time to learn about and understand the issues.
A good example of things to consider is documented at The Dangers of String-Comparing Passwords | Michael's Security Blog and through this you will see that you need to alter the way you think.