<?php
/**
 * Secure password hashing class example
 * @package secure_hash
 * @author Julius Beckmann 
 * @link http://juliusbeckmann.de/classes/secure_hash/
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 * @filesource
 */
/**
 * Example how to use secure_hash
 * @name Secure password hashing class example
 * @access public
 * @package secure_hash
 */

/**
 * Password we want to hash.
 */
$password 'GoodPassword';
echo 
"Our password: '$password' <br/>\n";

/**
 * Create secure_hash object.
 */
require_once('secure_hash.class.php');
$secure_hash = new secure_hash;

/**
 * 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";
}else{
    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";
}else{
    echo 
"Password '$password' DOES NOT fit to the hash.<br/>\n";
}



?>