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?
I now read the code for bcrypt above, and you're consistent with that implementation. Maybe both should be rewritten? But that should probably go into another issue.