Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Wordpress hash password and return results - Alfred Workflow
/**
* This php script queries a form at
* http://scriptserver.mainframe8.com/wordpress_password_hasher.php to get a
* hashed version of a provided or default password
*
* This script is run using the command 'wpash <password>'. If the command is run without
* any parameters it will return the hash of the string 'password'. If a parameter is provided
* (example: 'wpash P@s$w0rD'), this script will return the hash of the string 'P@s$w0rD'
* This can be used in an Alfred Workflow to hash passwords for Wordpress sites. A great tool
* for developers who manage databases for a lot of Wordpress sites
*
*/
// Query in the form of one parameter 'password' to hash
$query = "{query}";
$password = '';
// There are no arguments...
if( empty( $query ) ){
// No provided password, use default 'password'
$password = 'password';
}
// At least 1 argument exists
else{
// Turn query string into params array
$params = explode(' ', $query);
// Get provided password (use first param, ignore others)
$password = $params[0];
}
// Url of password hashing tool for wordpress
$hashUrl = 'http://scriptserver.mainframe8.com/wordpress_password_hasher.php';
$data = array('phrase' => $password);
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data))
);
$context = stream_context_create($options);
$output = file_get_contents( $hashUrl, false, $context );
// Extract hash
$first_step = explode( '<strong>' , $output );
$second_step = explode('</strong>' , $first_step[1] );
echo $second_step[0];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.