password.inc

Version 1.9 (checked in on 2010/12/18 at 00:56:18 by dries)

Secure password hashing functions for user authentication.

Based on the Portable PHP password hashing framework.

See also

http://www.openwall.com/phpass/

An alternative or custom version of this password hashing API may be used by setting the variable password_inc to the name of the PHP file containing replacement user_hash_password(), user_check_password(), and user_needs_new_hash() functions.

Constants

NameDescription
DRUPAL_HASH_COUNTThe standard log2 number of iterations for password stretching. This should increase by 1 every Drupal version in order to counteract increases in the speed and power of computers available to crack the hashes.
DRUPAL_HASH_LENGTHThe expected (and maximum) number of characters in a hashed password.
DRUPAL_MAX_HASH_COUNTThe maximum allowed log2 number of iterations for password stretching.
DRUPAL_MIN_HASH_COUNTThe minimum allowed log2 number of iterations for password stretching.

Functions & methods

NameDescription
user_check_passwordCheck whether a plain text password matches a stored hashed password.
user_hash_passwordHash a password using a secure hash.
user_needs_new_hashCheck whether a user's hashed password needs to be replaced with a new hash.
_password_base64_encodeEncode bytes into printable base 64 using the *nix standard from crypt().
_password_cryptHash a password using a secure stretched hash.
_password_enforce_log2_boundariesEnsures that $count_log2 is within set bounds.
_password_generate_saltGenerates a random base 64-encoded salt prefixed with settings for the hash.
_password_get_count_log2Parse the log2 iteration count from a stored hash or setting string.
_password_itoa64Returns a string for mapping an int to the corresponding base 64 character.