PHP code example of edwinmugendi / hashdigest

1. Go to this page and download the library: Download edwinmugendi/hashdigest library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

edwinmugendi / hashdigest example snippets



HashDigest\Digester;

$dataToHash = array(
    'name'=>'Ali',
    'age'=>'12',
    'city'=>'Nairobi',
    'work'=>'Software Engineer',
    'at'=>'Sapama.com'
);

$hash = Digester::digest($dataToHash);

echo 'Generated Hash is ';
echo "\n";
echo $hash;
echo "\n";
$isValid = Digester::isHashValid($hash, $dataToHash);

echo "Hash is ". ($isValid ? 'valid': 'not valid');




$dataToHash = array(
    'name'=>'Ali',
    'age'=>'12',
    'city'=>'Nairobi',
    'work'=>'Software Engineer',
    'at'=>'Sapama.com'
);

$hash = Digester::digest($dataToHash);



$dataToHash = array(
    'age'=>'12',
    'at'=>'Sapama.com'
    'city'=>'Nairobi',
    'name'=>'Ali',
    'work'=>'Software Engineer'
);


$stringToHash = '12.Sapama.com.Nairobi.Ali.Software Engineer'


$hash = '87304e9ab39f1d9c70b9f51f9f3b70fed5d19fbd3917ea3678115c5adffcf0d5';