1. Go to this page and download the library: Download effectra/security library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
useEffectra\Security\Hash;
$password = 'password123';
$hashedPassword = Hash::setPassword($password);
echo"Hashed password: " . $hashedPassword;
$isPasswordValid = Hash::verifyPassword($password, $hashedPassword);
if ($isPasswordValid) {
echo"Password is valid.";
} else {
echo"Password is invalid.";
}
useEffectra\Security\Csrf;
useEffectra\Session\Session; // Replace with your own session implementation// Initialize the CSRF class with a session instance
$session = new Session();
$csrf = new Csrf($session);
// Generate and insert a CSRF token in your HTML form
$html = '<form>';
$html .= $csrf->insertHiddenToken();
$html .= '<input type="submit" value="Submit">';
$html .= '</form>';
echo $html;
// Validate the CSRF token on form submissionif ($csrf->validate()) {
echo"CSRF token is valid.";
} else {
echo"CSRF token is invalid.";
}