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