wp_hash_password

The timeline below displays how wordpress function wp_hash_password has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.5

/**
 * Creates a hash (encrypt) of a plain text password.
 *
 * For integration with other applications, this function can be overwritten to
 * instead use the other package password checking algorithm.
 *
 * @since 2.5.0
 *
 * @global PasswordHash $wp_hasher PHPass object.
 *
 * @param string $password Plain text user password to hash.
 * @return string The hash string of the password.
 */
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));
}

WordPress Version: 6.1

/**
 * Creates a hash (encrypt) of a plain text password.
 *
 * For integration with other applications, this function can be overwritten to
 * instead use the other package password checking algorithm.
 *
 * @since 2.5.0
 *
 * @global PasswordHash $wp_hasher PHPass object
 *
 * @param string $password Plain text user password to hash.
 * @return string The hash string of the password.
 */
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));
}

WordPress Version: 5.4

/**
 * Create a hash (encrypt) of a plain text password.
 *
 * For integration with other applications, this function can be overwritten to
 * instead use the other package password checking algorithm.
 *
 * @since 2.5.0
 *
 * @global PasswordHash $wp_hasher PHPass object
 *
 * @param string $password Plain text user password to hash
 * @return string The hash string of the password
 */
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));
}

WordPress Version: 4.8

/**
 * Create a hash (encrypt) of a plain text password.
 *
 * For integration with other applications, this function can be overwritten to
 * instead use the other package password checking algorithm.
 *
 * @since 2.5.0
 *
 * @global PasswordHash $wp_hasher PHPass object
 *
 * @param string $password Plain text user password to hash
 * @return string The hash string of the password
 */
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));
}

WordPress Version: 4.7

/**
 * Create a hash (encrypt) of a plain text password.
 *
 * For integration with other applications, this function can be overwritten to
 * instead use the other package password checking algorithm.
 *
 * @since 2.5.0
 *
 * @global PasswordHash $wp_hasher PHPass object
 *
 * @param string $password Plain text user password to hash
 * @return string The hash string of the password
 */
function wp_hash_password($password)
{
    global $wp_hasher;
    if (empty($wp_hasher)) {
        // By default, use the portable hash from phpass
        $wp_hasher = new PasswordHash(8, true);
    }
    return $wp_hasher->HashPassword(trim($password));
}

WordPress Version: 4.3

/**
 * Create a hash (encrypt) of a plain text password.
 *
 * For integration with other applications, this function can be overwritten to
 * instead use the other package password checking algorithm.
 *
 * @since 2.5.0
 *
 * @global PasswordHash $wp_hasher PHPass object
 *
 * @param string $password Plain text user password to hash
 * @return string The hash string of the password
 */
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));
}

WordPress Version: 4.0

/**
 * Create a hash (encrypt) of a plain text password.
 *
 * For integration with other applications, this function can be overwritten to
 * instead use the other package password checking algorithm.
 *
 * @since 2.5.0
 *
 * @global object $wp_hasher PHPass object
 * @uses PasswordHash::HashPassword
 *
 * @param string $password Plain text user password to hash
 * @return string The hash string of the password
 */
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));
}

WordPress Version: 3.9

/**
 * Create a hash (encrypt) of a plain text password.
 *
 * For integration with other applications, this function can be overwritten to
 * instead use the other package password checking algorithm.
 *
 * @since 2.5.0
 *
 * @global object $wp_hasher PHPass object
 * @uses PasswordHash::HashPassword
 *
 * @param string $password Plain text user password to hash
 * @return string The hash string of the password
 */
function wp_hash_password($password)
{
    global $wp_hasher;
    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);
    }
    return $wp_hasher->HashPassword(trim($password));
}

WordPress Version: 3.7

/**
 * Create a hash (encrypt) of a plain text password.
 *
 * For integration with other applications, this function can be overwritten to
 * instead use the other package password checking algorithm.
 *
 * @since 2.5
 * @global object $wp_hasher PHPass object
 * @uses PasswordHash::HashPassword
 *
 * @param string $password Plain text user password to hash
 * @return string The hash string of the password
 */
function wp_hash_password($password)
{
    global $wp_hasher;
    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);
    }
    return $wp_hasher->HashPassword(trim($password));
}