Source for file secure_hash.example.php
Documentation is available at secure_hash.example.php
* Secure password hashing class example
* @author Julius Beckmann
* @link http://juliusbeckmann.de/classes/secure_hash/
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* Example how to use secure_hash
* @name Secure password hashing class example
* Password we want to hash.
$password = 'GoodPassword';
echo "Our password: '$password' <br/>\n";
* Create secure_hash object.
require_once('secure_hash.class.php');
* Create a new permutation rule if needed
* Read documentation about this method!
//echo 'New permutation: '.$secure_hash->_new_permutation()."<br/>\n";
* Setting a global salt which is NOT saved in formated hash.
* Read documentation about this value!
$secure_hash->salt_global = '';
* Changing hashing method.
$secure_hash->hashing_method = 'sha1';
* Generate formated hash.
$hash = $secure_hash->hash($password);
echo "Formated hash: '$hash' <br/>\n";
* Test generated hash against password.
if($secure_hash->check($hash, $password)) {
echo "Password '$password' fits to the hash.<br/>\n";
echo "Password '$password' DOES NOT fit to the hash.<br/>\n";
* Test a incorrect password against hash.
$password = 'incorrect password';
if($secure_hash->check($hash, $password)) {
echo "Password '$password' fits to the hash.<br/>\n";
echo "Password '$password' DOES NOT fit to the hash.<br/>\n";
|