PHPackages                             3ncr/tokencrypt-php - 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. 3ncr/tokencrypt-php

ActiveLibrary[Security](/categories/security)

3ncr/tokencrypt-php
===================

Implementation of 3ncr.org V1 token(strings) encryption standard.

1.0.6(3y ago)018.8k↓50%1[1 PRs](https://github.com/3ncr/tokencrypt-php/pulls)MITPHPPHP &gt;=7.2.0CI failing

Since Nov 19Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/3ncr/tokencrypt-php)[ Packagist](https://packagist.org/packages/3ncr/tokencrypt-php)[ RSS](/packages/3ncr-tokencrypt-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (2)Versions (7)Used By (0)

tokencrypt-php (3ncr.org)
=========================

[](#tokencrypt-php-3ncrorg)

[![Latest Stable Version](https://camo.githubusercontent.com/86059f9a12abd8f1ab1cf1b18b34a0b6c7dffa424a549ca99727e75ae07a7623/68747470733a2f2f706f7365722e707567782e6f72672f336e63722f746f6b656e63727970742d7068702f762f737461626c65)](https://packagist.org/packages/3ncr/tokencrypt-php) [![Total Downloads](https://camo.githubusercontent.com/333374bd78b9b3e9c1732d001de4af33db8570b59303ea72960a701082a8f8f2/68747470733a2f2f706f7365722e707567782e6f72672f336e63722f746f6b656e63727970742d7068702f646f776e6c6f616473)](https://packagist.org/packages/3ncr/tokencrypt-php) [![License](https://camo.githubusercontent.com/abb083f86b231716511878d9e9e6b983371dc4361662b73dbeece20b4539b8b0/68747470733a2f2f706f7365722e707567782e6f72672f336e63722f746f6b656e63727970742d7068702f6c6963656e7365)](https://packagist.org/packages/3ncr/tokencrypt-php) [![Build Status](https://github.com/3ncr/tokencrypt-php/actions/workflows/lint-and-test.yml/badge.svg)](https://github.com/3ncr/tokencrypt-php/actions/workflows/lint-and-test.yml/badge.svg)

3ncr.org is a standard for string encryption/decryption (algorithms + storage format). Originally it was intended for encryption tokens in configuration files.

3ncr.org v1 uses AES-256-GCM and is fairly simple:

```
    header + base64(iv + data + tag)

```

Encrypted data looks like this `3ncr.org/1#pHRufQld0SajqjHx+FmLMcORfNQi1d674ziOPpG52hqW5+0zfJD91hjXsBsvULVtB017mEghGy3Ohj+GgQY5MQ`

This is a PHP 7.2+ implementation.

Usage
-----

[](#usage)

```
$tokenCrypt = new \ThreeEncr\TokenCrypt($secret, $salt, 1000);
```

`$secret` and `$salt` - are encryption keys (technically one of them is key, another is salt, but you need to store them both somewhere, preferably in different places).

You can store them any preferred places: environment variables, files, shared memory, drive from serial numbers or MAC. Be creative.

`1000` - is a number of PBKDF2 rounds. The more is slower. If you are sure that your secrets have 256 bit of entropy and fairly random, you can use '1' (essentially HMAC SHA3 hash)

After you created the class instance, you can just use encrypt3ncr and decrypt3ncr methods (they accept and return strings):

```
$token = '08019215-B205-4416-B2FB-132962F9952F'; // your secret you want to encrypt
$encryptedSecretToken = $tokenCrypt->encrypt3ncr($token);
// now $encryptedSecretToken === '3ncr.org/1#pHRufQld0SajqjHx+FmLMcORfNQi1d674ziOPpG52hqW5+0zfJD91hjXsBsvULVtB017mEghGy3Ohj+GgQY5MQ'

// ... some time later in another context ...

$decryptedSecretToken = $tokenCrypt->decrypt3ncr($encryptedSecretToken);
// now $decryptedSecretToken === ''08019215-B205-4416-B2FB-132962F9952F';
```

Or you can read JSON-file and decrypt its values:

```
$encConfig = json_decode(file_get_contents('config.json'), false);
$config = $token->decrypt3ncrArray($encConfig);

```

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance53

Moderate activity, may be stable

Popularity26

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.2% 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 ~221 days

Total

5

Last Release

1124d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/994900?v=4)[Andrian Budantsov](/maintainers/AndrianBdn)[@AndrianBdn](https://github.com/AndrianBdn)

---

Top Contributors

[![AndrianBdn](https://avatars.githubusercontent.com/u/994900?v=4)](https://github.com/AndrianBdn "AndrianBdn (20 commits)")[![pkotets](https://avatars.githubusercontent.com/u/99185488?v=4)](https://github.com/pkotets "pkotets (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/3ncr-tokencrypt-php/health.svg)

```
[![Health](https://phpackages.com/badges/3ncr-tokencrypt-php/health.svg)](https://phpackages.com/packages/3ncr-tokencrypt-php)
```

###  Alternatives

[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[mews/purifier

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

2.0k16.7M113](/packages/mews-purifier)[robrichards/xmlseclibs

A PHP library for XML Security

41478.1M118](/packages/robrichards-xmlseclibs)[bjeavons/zxcvbn-php

Realistic password strength estimation PHP library based on Zxcvbn JS

87117.5M63](/packages/bjeavons-zxcvbn-php)[illuminate/encryption

The Illuminate Encryption package.

9229.7M280](/packages/illuminate-encryption)[paragonie/hidden-string

Encapsulate strings in an object to hide them from stack traces

7410.6M39](/packages/paragonie-hidden-string)

PHPackages © 2026

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