PHP code example of yohns / hash
1. Go to this page and download the library: Download yohns/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/ */
yohns / hash example snippets
use Yohns\Security\Finding\Hash;
$token = Hash::generateToken('form-id'); // This value will be used again to validate the token
// add token to form
echo '<input type="hidden" name="YohnsPatch" value="'.$token.'">';
use Yohns\Security\Finding\Hash;
$isValid = Hash::validateToken('form-id', $_POST['YohnsPatch']);
if ($isValid) {
echo 'Token is valid!';
} else {
echo 'Token is invalid or expired.';
}
use Yohns\Security\Finding\Hash;
Hash::garbageCollect();
echo 'Expired tokens removed.';