PHPackages                             webiik/token - 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. [Security](/categories/security)
4. /
5. webiik/token

ActiveLibrary[Security](/categories/security)

webiik/token
============

The Token generates and compares tokens.

1.0(7y ago)01574MITPHPPHP &gt;=7.2

Since Feb 28Pushed 7y ago1 watchersCompare

[ Source](https://github.com/webiik/token)[ Packagist](https://packagist.org/packages/webiik/token)[ Docs](https://www.webiik.com)[ RSS](/packages/webiik-token/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (2)Used By (4)

[![](https://camo.githubusercontent.com/a397347ee4fb199934fee6354504f4702b89f5c22f0ce0ba94c5ff691cde545c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f77656269696b2f77656269696b2e737667)](https://camo.githubusercontent.com/a397347ee4fb199934fee6354504f4702b89f5c22f0ce0ba94c5ff691cde545c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f77656269696b2f77656269696b2e737667)[![](https://camo.githubusercontent.com/20f4b99a958aadb02ff273ac6428c17cf55c6b817657ed64b1c39c7f71955a0e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646570656e64656e636965732d302d627269676874677265656e2e737667)](https://camo.githubusercontent.com/20f4b99a958aadb02ff273ac6428c17cf55c6b817657ed64b1c39c7f71955a0e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646570656e64656e636965732d302d627269676874677265656e2e737667)

Token
=====

[](#token)

The Token generates and compares tokens.

Installation
------------

[](#installation)

```
composer require webiik/token
```

Example
-------

[](#example)

```
$token = new \Webiik\Token\Token();
$secureToken = $token->generate();
if ($token->compare('vuefjsdfk', $secureToken)) {
    // Tokens are equal
}
```

Generating
----------

[](#generating)

### generate

[](#generate)

```
generate($strength = 16): string
```

**generate()** returns safe token. By default the token is 32 characters long. It throws Exception when it was not possible to generate safe token.

```
try {
    $token->generate();
} catch (Exception $exception) {
    // Unable to generate strong token
}
```

### generateCheap

[](#generatecheap)

```
generateCheap($length = 32): string
```

**generateCheap()** returns cheap token. By default the token is 32 characters long. Cheap token is not safe, but is faster to generate.

```
$token->generateCheap();
```

Comparison
----------

[](#comparison)

### compare

[](#compare)

```
compare(string $original, string $imprint): bool
```

**compare()** Compares two strings using the same time whether they're equal or not - Timing attack safe string comparison.

```
$token->compare('known-string', 'user-string');
```

> Timing-attack safe comparison is slower than regular comparison.

Resources
---------

[](#resources)

- [Webiik framework](https://github.com/webiik/webiik)
- [Report issue](https://github.com/webiik/components/issues)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity55

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

Unknown

Total

1

Last Release

2633d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1226362d003d186b45e7dfa44489c36af37196c6a1b476206700eaf4e9c96a5a?d=identicon)[Jiri Mihal](/maintainers/Jiri%20Mihal)

---

Top Contributors

[![Jiri-Mihal](https://avatars.githubusercontent.com/u/10408123?v=4)](https://github.com/Jiri-Mihal "Jiri-Mihal (267 commits)")

---

Tags

token

### Embed Badge

![Health badge](/badges/webiik-token/health.svg)

```
[![Health](https://phpackages.com/badges/webiik-token/health.svg)](https://phpackages.com/packages/webiik-token)
```

###  Alternatives

[roave/security-advisories

Prevents installation of composer packages with known security vulnerabilities: no API, simply require it

2.9k97.3M6.4k](/packages/roave-security-advisories)[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k16.7M113](/packages/mews-purifier)[kelvinmo/fernet-php

An implementation of the Fernet token specification in PHP.

211.7M3](/packages/kelvinmo-fernet-php)[kunststube/csrfp

A signed token generator for cross site request forgery protection.

52209.5k1](/packages/kunststube-csrfp)[acmephp/ssl

PHP wrapper around OpenSSL extension providing SSL encoding, decoding, parsing and signing features

141.2M4](/packages/acmephp-ssl)

PHPackages © 2026

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