compatibility with sha512

These changes add support for sha512 hashing algorithm. This is often required for compatibility with applications that don't support bcrypt.

I am far from an expert on this level, but these changes work fine on our setup. What are your thoughts?