CoreFiles by mySites.guru
PHPassHandler.php90 lines, 2,072 bytes, from Joomla_4.0.0-alpha2-Alpha-Full_Package.zip
Raw History Compare with 3.10.0-alpha9
md5
3260f7ff4af0f6f43dc7795aeafc508b
sha1
d353e3096d9c3bbb519f803bcc1039e3d5a9d4e4
sha256
9af53e827ffd0e1d95264d407418b94e488685f28a901f353d0ffcbbfd1e0100
<?php
/**
 * Joomla! Content Management System
 *
 * @copyright  Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\CMS\Authentication\Password;

defined('JPATH_PLATFORM') or die;

use Joomla\Authentication\Password\HandlerInterface;

/**
 * Password handler for PHPass hashed passwords
 *
 * @since       __DEPLOY_VERSION__
 * @deprecated  5.0  Support for PHPass hashed passwords will be removed
 */
class PHPassHandler implements HandlerInterface, CheckIfRehashNeededHandlerInterface
{
	/**
	 * Check if the password requires rehashing
	 *
	 * @param   string  $hash  The password hash to check
	 *
	 * @return  boolean
	 *
	 * @since   __DEPLOY_VERSION__
	 */
	public function checkIfRehashNeeded(string $hash): bool
	{
		return true;
	}

	/**
	 * Generate a hash for a plaintext password
	 *
	 * @param   string  $plaintext  The plaintext password to validate
	 * @param   array   $options    Options for the hashing operation
	 *
	 * @return  string
	 *
	 * @since   __DEPLOY_VERSION__
	 */
	public function hashPassword($plaintext, array $options = [])
	{
		return $this->getPasswordHash()->HashPassword($plaintext);
	}

	/**
	 * Check that the password handler is supported in this environment
	 *
	 * @return  boolean
	 *
	 * @since   __DEPLOY_VERSION__
	 */
	public static function isSupported()
	{
		return class_exists(\PasswordHash::class);
	}

	/**
	 * Validate a password
	 *
	 * @param   string  $plaintext  The plain text password to validate
	 * @param   string  $hashed     The password hash to validate against
	 *
	 * @return  boolean
	 *
	 * @since   __DEPLOY_VERSION__
	 */
	public function validatePassword($plaintext, $hashed)
	{
		return $this->getPasswordHash()->CheckPassword($plaintext, $hashed);
	}

	/**
	 * Get an instance of the PasswordHash class
	 *
	 * @return  \PasswordHash
	 *
	 * @since   __DEPLOY_VERSION__
	 */
	private function getPasswordHash(): \PasswordHash
	{
		return new \PasswordHash(10, true);
	}
}

No other release has this exact content. See every version of this file.