lib: Refactor password algorithm into crypt.php

Issue #121.