Uname: Linux info 3.0 #1337 SMP Tue Jan 01 00:00:00 CEST 2000 all GNU/Linux
Software: Apache
PHP version: 5.6.40 [ PHP INFO ] PHP os: Linux
Server Ip: 217.160.0.194
Your Ip: 216.73.217.62
User: u72294154 (9179942) | Group: ftpusers (600)
Safe Mode: OFF
Disable Function:
NONE

name : drupal.php
<?php
/**
 * An example file demonstrating the generation and validation of Drupal
 * Passwords (new Style)
 *
 * PHP version 5.3
 *
 * @category   PHPCryptLib-Examples
 * @package    Password
 * @author     Anthony Ferrara <ircmaxell@ircmaxell.com>
 * @copyright  2011 The Authors
 * @license    http://opensource.org/licenses/bsd-license.php New BSD License
 * @license    http://www.gnu.org/licenses/lgpl-2.1.html LGPL v 2.1
 */

namespace CryptLibExamples\Password;

//We first load the bootstrap file so we have access to the library
require_once dirname(dirname(__DIR__)) . '/lib/CryptLib/bootstrap.php';

/**
 * Now, let's create a password that's compatible with Drupal
 */

// First, let's create an instance of Drupal, where 15 is the iteration count for D7
$hasher = new \CryptLib\Password\Implementation\Drupal(15);

$password = 'FooBarBaz';

// Now, let's create a password hash of the password "FooBarBaz"
$hash = $hasher->create($password);

//It's safe to print, so let's output it:
printf(
    "Password: %s\nHash: %s\n\n",
    $password,
    $hash
);

/**
 * Now, we can also verify any passwords created by Drupal. First, let's load a hash.
 *
 * This works, because it detects the iteration count that's stored in the hash, and
 * pre-configures our instance for us.
 */
$hasher2 = \CryptLib\Password\Implementation\Drupal::loadFromHash($hash);

/**
 * Next, we verify the hash with the expected password.
 */
$test = $hasher2->verify($password, $hash);

/**
 * $test should now contain a boolean value as to the validity of the hash
 */
printf(
    "Verification was %s\n\n",
    $test ? "Successful!" : "Failed!"
);
© 2026 GrazzMean