<?php
//ghostHash 1.0 example usage
$key = 'thisismypassword';
$salt = 'addadashofsalt';
//checking to see if ghostHash is pre-loaded
if( !method_exists('ghostHash','quickHash') ){
echo '<br>ghostHash is not pre-loaded, attempting to find file';
if( !is_file('ghost.class.php') ){
echo '<br>ghost.class.php file not found, aborting';
die;
}else{
echo '<br>ghostHash found, loading file. You should consider pre-loading the file';
include('ghost.class.php');
}
}else{
echo '<br>Good news, ghostHash is pre-loaded in the system';
}
//example usage
echo "<hr>Returning a quick hash -> ghostHash::quickHash(string key[,string salt=''][,string pepper=''])";
$hash = ghostHash::quickHash($key,$salt);
echo '<br>'.$hash;
echo "<hr>Verifying the quick hash -> ghostHash::verifyQuickHash(string key, string hash[,string salt=''][,string pepper=''])";
$result = ghostHash::verifyQuickHash($key,$hash,$salt);
echo '<br>';
echo ( $result === true ) ? 'Verified' : 'Failed verification';
echo "<hr>Getting the best cost value -> ghostHash::calculateCost(void)";
$cost = ghostHash::calculateCost();
echo '<br>'.$cost;
echo "<hr>Returning a strong hash -> ghostHash::strongHash(string key[,cost=10])";
$hash = ghostHash::strongHash($key,$cost);
echo '<br>'.$hash;
echo "<hr>Verifying the strong hash -> ghostHash::verifyStrongHash(string key, string hash)";
$result = ghostHash::verifyStrongHash($key,$hash);
echo '<br>';
echo ( $result === true ) ? 'Verified' : 'Failed verification';
echo "<hr>Determine if strong hash needs to be rehashed -> ghostHash::newStrongHash(string hash[,int cost=10])";
$result = ghostHash::newStrongHash($hash,$cost);
echo '<br>';
echo ( $result === true ) ? 'Needs a new hash' : 'Hash properties are good';
echo "<hr>Getting information on strong hash -> ghostHash::strongHashInfo(string hash)";
echo '<br>';
var_dump(ghostHash::strongHashInfo($hash));
?>
|