1. Go to this page and download the library: Download lamansky/hash 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/ */
lamansky / hash example snippets
use Lamansky\Hash\Hash;
//Hash a string
echo Hash::generate('md5', 'test')->toHex(); //098f6bcd4621d373cade4e832627b4f6
//Generate random 128-bit and 256-bit tokens
$a = Hash::generateRandom(128);
$b = Hash::generateRandom(256);
//Timing-safe comparison
var_dump($a->equals($b)); //bool(false)
//Convert Hash to hex string
$hex = $a->toHex();
echo $hex; //4df3fa5a70eaa4097740b46017d428e2
//Compare Hash with string
var_dump($a->equals($hex)); //bool(true)
//Turn string back into a Hash
$c = new Hash(128, $hex);
var_dump($c->equals($a)); //bool(true)