The second one is a timing issue. You need to have an equality method that takes an equal amount of time on success or failure.
Heres a good read on timing attacks in general: http://codahale.com/a-lesson-in-timing-attacks/
Heres a good read on timing attacks in general: http://codahale.com/a-lesson-in-timing-attacks/