PHPackages                             alexeichhorn/json-work-proof - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. alexeichhorn/json-work-proof

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

alexeichhorn/json-work-proof
============================

JSON Work Proof (JWP) - proof-of-work algorithm

0.1.3(5y ago)013MITPHP

Since Mar 28Pushed 4y ago1 watchersCompare

[ Source](https://github.com/alexeichhorn/php-json-work-proof)[ Packagist](https://packagist.org/packages/alexeichhorn/json-work-proof)[ Docs](https://losjet.com)[ RSS](/packages/alexeichhorn-json-work-proof/feed)WikiDiscussions main Synced today

READMEChangelog (4)DependenciesVersions (5)Used By (0)

JSON Work Proof
===============

[](#json-work-proof)

JSON Work Proof is a proof-of-work algorithm that creates a token after doing some workload. This token contains certain claims defined by you and verifies that you did this work at this time and for these claims.

It packs the security of the Hashcash algorithm *(used for Bitcoin in a similar way)* into a modern JWT-like token.

Structure of Token
------------------

[](#structure-of-token)

A token looks like this: `eyJ0eXAiOiJKV1AiLCJhbGciOiJTSEEyNTYiLCJkaWYiOjIwfQ.eyJleHAiOjE2MTY4NTA1NzAuNjU1MTQ3MSwiaGVsbG8iOiJ3b3JsZCJ9.VE6YYxIQ46lPzxyNuRYAmAMkEM`. It has the same structure as a JWT token and can therefore also be inspected on the Debugger on [jwt.io](https://jwt.io). It contains three elements which are each base64url encoded. The header contains the type of the token (JWP), the hash algorithm used for the challenge (currently only SHA256 supported) and the difficulty at which the token was mined. The payload consists of the claims you specified and optionally an expiration date. The last part contains a salt and a big number (named counter in Hashcash). The work needed to generate a token is actually to find this number. It's hard to find this number, but easy to verify it's correct. (Read more about how it works on [Wikipedia](https://en.wikipedia.org/wiki/Hashcash))

Possible Applications
---------------------

[](#possible-applications)

Can be used to prevent DDOS attacks or as an alternative to rate limiting or captchas.

E.g. you can use this to prevent brute forcing user logins: The client generates a token with the claims including username and password and sends it along with the login request. The server then first checks if the token is valid before it does any lookup. The scale of bruteforcing can therefore be massively reduced.

Usage
-----

[](#usage)

**Note:** Currently only decoding is supported in PHP.

### General

[](#general)

To generate and validate tokens you need to use a `JWP`-object. On creation you can specify the `difficulty`, which determines how hard the challenge should be. It defaults to `20`, which takes about a second to compute on an average computer. Each increment by one, doubles the difficulty and therefore the time it takes to generate.

```
use JSONWorkProof\JWP;

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

### Generation

[](#generation)

Currenlty not supported in PHP

### Validation

[](#validation)

To check if a token is valid for a certain difficulty and to read the claims:

```
$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";
}
```

If you just want to read the claims without verifying the proof and expiration date, you can use this instead:

```
$claims = jwp.decode(token, false)
```

It expects the expiration date to be between now and 30 minutes in the future.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

1922d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10730702?v=4)[Alexander Eichhorn](/maintainers/alexeichhorn)[@alexeichhorn](https://github.com/alexeichhorn)

---

Top Contributors

[![alexeichhorn](https://avatars.githubusercontent.com/u/10730702?v=4)](https://github.com/alexeichhorn "alexeichhorn (11 commits)")

---

Tags

jwtjsonvalidationtokenproof-of-workHashcash

### Embed Badge

![Health badge](/badges/alexeichhorn-json-work-proof/health.svg)

```
[![Health](https://phpackages.com/badges/alexeichhorn-json-work-proof/health.svg)](https://phpackages.com/packages/alexeichhorn-json-work-proof)
```

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k103.2M103](/packages/namshi-jose)[psecio/jwt

A JWT (JSON Web Token) Encoding &amp; Decoding library

109362.5k2](/packages/psecio-jwt)[rbdwllr/reallysimplejwt

A really simple library to generate user authentication JSON Web Tokens.

2902.5M23](/packages/rbdwllr-reallysimplejwt)[adhocore/jwt

Ultra lightweight JSON web token (JWT) library for PHP5.5+.

3031.8M29](/packages/adhocore-jwt)[nowakowskir/php-jwt

JSON Web Token implementation for PHP.

41279.7k8](/packages/nowakowskir-php-jwt)[sop/jwx

A PHP library for JSON web tokens (JWT) with signature (JWS) and encryption (JWE) support.

26287.3k1](/packages/sop-jwx)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
