wppaste
WordPress

PasswordHash

Since
2.5.0
Source
wp-includes/class-phpass.php:44
Portable PHP password hashing framework.

Compatibility

WordPress
since 2.5.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Properties · 4

$itoa64public
$iteration_count_log2public
$portable_hashespublic
$random_statepublic

Methods · 9

Source code

class PasswordHash {	var $itoa64;	var $iteration_count_log2;	var $portable_hashes;	var $random_state; 	function __construct($iteration_count_log2, $portable_hashes)	{		$this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; 		if ($iteration_count_log2 < 4 || $iteration_count_log2 > 31) {			$iteration_count_log2 = 8;		}		$this->iteration_count_log2 = $iteration_count_log2; 		$this->portable_hashes = $portable_hashes; 		$this->random_state = microtime();		if (function_exists('getmypid')) {			$this->random_state .= getmypid();		}	} 	function PasswordHash($iteration_count_log2, $portable_hashes)	{		self::__construct($iteration_count_log2, $portable_hashes);	} 	function get_random_bytes($count)	{		$output = '';		if (@is_readable('/dev/urandom') &&		    ($fh = @fopen('/dev/urandom', 'rb'))) {			$output = fread($fh, $count);			fclose($fh);		} 		if (strlen($output) < $count) {			$output = '';			for ($i = 0; $i < $count; $i += 16) {				$this->random_state =				    md5(microtime() . $this->random_state);				$output .= md5($this->random_state, TRUE);			}			$output = substr($output, 0, $count);		} 		return $output;	} 	function encode64($input, $count)	{		$output = '';		$i = 0;		do {			$value = ord($input[$i++]);			$output .= $this->itoa64[$value & 0x3f];			if ($i < $count) {				$value |= ord($input[$i]) << 8;			}			$output .= $this->itoa64[($value >> 6) & 0x3f];			if ($i++ >= $count) {				break;			}			if ($i < $count) {				$value |= ord($input[$i]) << 16;			}			$output .= $this->itoa64[($value >> 12) & 0x3f];			if ($i++ >= $count) {				break;			}			$output .= $this->itoa64[($value >> 18) & 0x3f];		} while ($i < $count); 		return $output;	} 	function gensalt_private($input)	{		$output = '$P$';

Changelog

Introduced in 2.5.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/class-phpass.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.