by siyb

I have forgotten my Wordpress password recently and was unable to recover it using the provided email recovery. It took about 2 minutes to find out how Wordpress encrypts passwords, here is a small php-cli script that will return a valid password hash.

To generate a password hash you need to create a file in your Wordpress directory and grant appropriate rights:

cat > generateHash.php

… paste the script here and use ctrl+c to terminate cat once the script has been pasted

chmod 750 generateHash.php

./generateHash.php ..password..

The script:

#!/usr/bin/php
<?php
if (!isset($argv[1])) { echo "Please specify a password to hash\n"; return; }
include('wp-includes/class-phpass.php');
$wp_hasher = new PasswordHash(8, TRUE);
echo "PW: " . $argv[1] . " HASH: " . $wp_hasher->HashPassword($argv[1]) . "\n";
?>