PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

How is the password hashed?

s2Member Plugin. A Membership plugin for WordPress®.

How is the password hashed?

Postby davei234 » March 29th, 2011, 10:00 pm

Hi,

I was wondering how to check the password stored in the `user_pass` field in the 'wp_users' database table. It doesn't appear to be a normal md5 hash. I want to be able to check the passwords so I could use the same users from s2member to login via software. Thanks.

Dave
User avatar
davei234
Registered User
Registered User
 
Posts: 3
Joined: March 29, 2011

Re: How is the password hashed?

Postby davei234 » March 31st, 2011, 1:37 am

In other words:

md5 of "test":
098f6bcd4621d373cade4e832627b4f6
^^ this is easy to test for -- just do md5("test")

wordpress/s2member hash of "test":
$P$BMr8jTPjHHOl0g/P6OtOeT/fZZr71y0
^^ how do I test this password?

thanks..
User avatar
davei234
Registered User
Registered User
 
Posts: 3
Joined: March 29, 2011

Re: How is the password hashed?

Postby Jason Caldwell » March 31st, 2011, 4:35 am

Thanks for the excellent question.

You can use the "user_pass_ok()" function.
http://codex.wordpress.org/Function_Ref ... er_pass_ok
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: How is the password hashed?

Postby davei234 » March 31st, 2011, 12:45 pm

Thanks! By the way, here's how I was able to use user_pass_ok() outside of Wordpress:

Code: Select all
<?php

define( 'ABSPATH', dirname(__FILE__) . '/../web/' ); // directory of WordPress
require_once(ABSPATH.'wp-load.php');
require_once(ABSPATH.'wp-includes/wp-db.php');
require_once(ABSPATH.'wp-includes/cache.php');
require_once(ABSPATH.'wp-includes/formatting.php');
require_once(ABSPATH.'wp-includes/pluggable.php');
require_once(ABSPATH.'wp-includes/plugin.php');
require_once(ABSPATH.'wp-includes/user.php');

if (user_pass_ok("test", "test"))
{
   echo "good password";
}
else
{
   echo "bad password";
}

?>
User avatar
davei234
Registered User
Registered User
 
Posts: 3
Joined: March 29, 2011

Re: How is the password hashed?

Postby Jason Caldwell » March 31st, 2011, 8:47 pm

Nice work. Thanks for sharing this with us.
~ much appreciated!
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA


Return to s2Member Plugin

Who is online

Users browsing this forum: No registered users and 2 guests

cron