Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require_once( 'wp-includes/class-phpass.php' );
- $wp_hasher = new PasswordHash( 8, TRUE );
- $password = "passwordhere";
- $hashed_password = $wp_hasher->HashPassword( $password );
- $encryptedpass = md5($hashed_password);
- SELECT * FROM wp_customers WHERE email = "ccc@aaa.com" AND password = "<what goes here?>"
- function wp_check_password($password, $hash, $user_id = '') {
- global $wp_hasher;
- // If the hash is still md5...
- if ( strlen($hash) <= 32 ) {
- $check = ( $hash == md5($password) );
- if ( $check && $user_id ) {
- // Rehash using new hash.
- wp_set_password($password, $user_id);
- $hash = wp_hash_password($password);
- }
- return apply_filters('check_password', $check, $password, $hash, $user_id);
- }
- // If the stored hash is longer than an MD5, presume the
- // new style phpass portable hash.
- if ( empty($wp_hasher) ) {
- require_once ( ABSPATH . 'wp-includes/class-phpass.php');
- // By default, use the portable hash from phpass
- $wp_hasher = new PasswordHash(8, TRUE);
- }
- $check = $wp_hasher->CheckPassword($password, $hash);
- return apply_filters('check_password', $check, $password, $hash, $user_id);
- }
- function my_password_validation( $username, $password ) {
- // Select the users's password hash from the database
- $stored = query( 'SELECT * FROM wp_customers WHERE email = ' . $username );
- require_one( 'class-phpass.php' );
- $hasher = new PasswordHash(8, TRUE);
- return $hasher->CheckPassword( $password, $stored );
- }
- <?php
- include_once($_SERVER['DOCUMENT_ROOT'].'/wp-includes/class-phpass.php' );
- // prepare database connection
- $ip_address="localhost";
- $user_db="userdb";
- $pass_db="passdb";
- $conn= mysql_connect($ip_address,$user_db,$pass_db);
- mysql_select_db("dbname",$conn);
- if (!$conn){
- echo "Could not connect: " . mysql_error();
- exit();
- }
- // wordpress' username that his password going to compare
- $user = 'test';
- $user_name = htmlspecialchars($user,ENT_QUOTES);
- // plain password to compare
- $password = 'tespass';
- $hasher = new PasswordHash(8, TRUE);
- // get user_name's hashed password from wordpress database
- $queryx = "select * from wa1gty5f_users where user_login='$user_name'";
- $Resultx = mysql_query($queryx,$conn);
- while($row = mysql_fetch_array($Resultx)){
- $passnya = $row[user_pass];
- }
- // compare plain password with hashed password
- if ($hasher->CheckPassword( $password, $passnya )){
- echo "MATCHED";
- } else {
- echo "NO MATCHED";
- }
- ?>
- <?php
- $wp_hasher = new PasswordHash(8, TRUE);
- $password_hashed = '$P$B55D6LjfHDkINU5wF.v2BuuzO0/XPk/';
- $plain_password = 'test';
- if($wp_hasher->CheckPassword($plain_password, $password_hashed)) {
- echo "YES, Matched";
- } else {
- echo "No, Wrong Password";
- }
- ?>
Add Comment
Please, Sign In to add comment