wp_hash_password( string $password )

Create a hash (encrypt) of a plain text password.


Description Description

For integration with other applications, this function can be overwritten to instead use the other package password checking algorithm.


Parameters Parameters

$password

(string) (Required) Plain text user password to hash


Top ↑

Return Return

(string) The hash string of the password


Top ↑

Source Source

File: wp-includes/pluggable.php

	function wp_hash_password( $password ) {
		global $wp_hasher;

		if ( empty( $wp_hasher ) ) {
			require_once( ABSPATH . WPINC . '/class-phpass.php' );
			// By default, use the portable hash from phpass
			$wp_hasher = new PasswordHash( 8, true );
		}

		return $wp_hasher->HashPassword( trim( $password ) );
	}

Top ↑

Changelog Changelog

Changelog
Version Description
2.5.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Codex

    Compare an already hashed password with its plain-text string:

    <?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";
    }
    ?>
    
    

You must log in before being able to contribute a note or feedback.