PHP code example of alexeichhorn / json-work-proof

1. Go to this page and download the library: Download alexeichhorn/json-work-proof 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/ */

    

alexeichhorn / json-work-proof example snippets


use JSONWorkProof\JWP;

$jwp = new JWP(); # defaults to difficulty 20
$jwp_harder = new JWP(25);

$jwp = new JWP();
try {
  $claims = $jwp->decode($token);
} catch (JSONWorkProof\InvalidFormatException $e) {
  echo "The token is formatted incorrectly";
} catch (JSONWorkProof\InvalidProofException $e) {
  echo "The difficulty this token was created at is lower than what is specified in your JWP object";
} catch (JSONWorkProof\ExpiredException $e) {
  echo "The token expiration is too old or too new";
}

$claims = jwp.decode(token, false)