Fix PHP Warning on user login

While at it, I also extracted the hash function into it's own getHash
method. This will allow easy changes to hashing for string in the
future.

Fixes #382
Merge pull request #385 from TheSerapher/issue-382

Fix PHP Warning on user login