3 * The Drupal password hashing implementation
5 * Use this class to generate and validate Drupal password hashes.
9 * @see http://www.openwall.com/phpass/
10 * @category PHPCryptLib
12 * @subpackage Implementation
13 * @author Anthony Ferrara <ircmaxell@ircmaxell.com>
14 * @copyright 2011 The Authors
15 * @license http://www.opensource.org/licenses/mit-license.html MIT License
16 * @version Build @@version@@
19 namespace CryptLib\Password\Implementation
;
21 use CryptLib\Random\Factory
as RandomFactory
;
24 * The PHPASS password hashing implementation
26 * Use this class to generate and validate PHPASS password hashes.
28 * @see http://www.openwall.com/phpass/
29 * @category PHPCryptLib
31 * @subpackage Implementation
32 * @author Anthony Ferrara <ircmaxell@ircmaxell.com>
34 class Drupal
extends PHPASS
{
37 * @var string The prefix for the generated hash
39 protected static $prefix = '$S$';
42 * @var string The hash function to use for this instance
44 protected $hashFunction = 'sha512';
47 * Determine if the hash was made with this method
49 * @param string $hash The hashed data to check
51 * @return boolean Was the hash created by this method
53 public static function detect($hash) {
54 $prefix = preg_quote(static::$prefix, '/');
55 return 1 == preg_match('/^'.$prefix.'[a-zA-Z0-9.\/]{95}$/', $hash);