PHP code example of kumatch / casule
1. Go to this page and download the library: Download kumatch/casule 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/ */
kumatch / casule example snippets
use Kumatch\Casule\Casule;
$attributes = array("foo" => 123, "bar" => "baz");
$salt = 'saltstring';
$casule = new Casule($salt);
$token = $casule->create($attributes); // 'yBJwijCcdwrT0hXbeSIYvcWgP7U='
$algo = 'sha512';
$casule2 = new Casule($salt, $algo);
$token2 = $casule2->create($attributes); // 'MoxMmk+ACDlHH/PaRQhgCZHjtrolbOpb5GvpbYHzPMZKwDXelj5x3BfyEMkCsXaPwVx59tlHPTqo1E305NkTDA=='
if ( $casule->challenge($token, $attributes) ) {
echo 'valid token.';
}