UPDATE:: PHP 5.5 will have native password hashing functions that will make this conversation (and all associated confusion) obsolete!
BONUS:: there is a userland compatibility patch that you can use now (w/version 5.3.7+)!!
functions (same names/signatures for native and userland functions):
PHP Code:
<?php
/**
* password_hash(): Hash the password using the specified algorithm
*
* @param string $password The password to hash
* @param int $algo The algorithm to use (Defined by PASSWORD_* constants)
* @param array $options The options for the algorithm to use
*
* @return string|false The hashed password, or false on error.
*/
// example usage:
$hash = password_hash( 'password',PASSWORD_BCRYPT );
// returns "$2y$10$a6o9xrystDhNxm3PAxaS5.GxojspgIrhgb5tFSey7aIHHtzQCWxKK", ready to save in your DB!
/**
* password_verify(): Verify a password against a hash using a timing attack resistant approach
*
* @param string $password The password to verify
* @param string $hash The hash to verify against
*
* @return boolean If the password matches the hash
*/
// example usage:
$match = password_verify( 'password',$hash );
// returns TRUE - the password and hash match! Log them in!
############
// other functions are useful, but less immediately so:
// password_get_info(): Get information about options used to create a hash.
// password_needs_rehash(): Determine if the password hash needs to be rehashed according to the options provided
Celebrate!
Bookmarks