I am working with site that is done with WordPress, and I need to add some parts that are outside WP, and to check user login, but I can’t find how WP is encrypting password before it writes it in DB…
I tried with md5 but it’s not…
Does anyone know how to check password outside WP, without using it’s pluggins/checkers, clear PHP code?
The password encryption library is in /wp-includes/class-phpass.php. It is the Portable PHP Password hashing framework.
It sounds like you want to use external code to validate usernames/passwords against WP’s database. If that’s correct, you’re going to spend a lot of time reinventing the wheel. But for a good example of how to do this using straight PHP, it’s a good idea to take a look at the core WP functions that already do it.
Case in point, `wp_check_password()’:
First, WordPress checks to see if the user’s hashed password is still using old-school MD5 for security. This is to preserve backwards compatibility for updates. If the password is MD5, then WordPress will automatically replace it with a new hash using the new system (the call to
wp_set_password()
). If it isn’t MD5, then WP moves on to the newer hashing setup.First, we include the Portable PHP Hashing Framework (already mentioned by @John Watson in another answer) and create an instance of it, storing it in the global
$wp_hasher
variable.We then pass in the plaintext password and the hash to verify it against, using the
CheckPassword()
method of the library.If you want to use this in an external library, you’ll have to first
include
/require
the library, then instantiate it, then pass in your plain text password and its hash. So some untested psuedo-code …