PHPackages                             leigh/aead-chacha20-poly1305 - 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. leigh/aead-chacha20-poly1305

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

leigh/aead-chacha20-poly1305
============================

RFC 7539 ChaCha20/Poly1305 AEAD construction

0.2.1(10y ago)61483[2 issues](https://github.com/lt/PHP-AEAD-ChaCha20-Poly1305/issues)MITPHPPHP &gt;=7.0

Since Dec 21Pushed 9mo agoCompare

[ Source](https://github.com/lt/PHP-AEAD-ChaCha20-Poly1305)[ Packagist](https://packagist.org/packages/leigh/aead-chacha20-poly1305)[ Docs](https://github.com/lt/PHP-AEAD-ChaCha20-Poly1305)[ RSS](/packages/leigh-aead-chacha20-poly1305/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (3)Versions (4)Used By (0)

RFC 7539 ChaCha20/Poly1305 AEAD construction
============================================

[](#rfc-7539-chacha20poly1305-aead-construction)

This library contains a pure PHP implementation of the RFC 7539 ChaCha20/Poly1305 [AEAD construction](https://en.wikipedia.org/wiki/Authenticated_encryption).

### Usage:

[](#usage)

Remember that *a nonce must not be used more than once for a particular key*

The library contains both one-shot functions for small amounts of data, and methods for processing streams of information without consuming large amounts of memory.

*One-shot functions*

```
// Encrypt and produce a ciphertext and tag.
list($ciphertext, $tag) = \ChaCha20Poly1305\encrypt($key, $nonce, $aad, $plaintext);

// Decrypt and produce a plaintext, throw an exception if the tag is invalid.
$plaintext = \ChaCha20Poly1305\decrypt($key, $nonce, $aad, $plaintext, $tag);

// Verify without decryption, return true/false depending the tag being valid.
$valid = \ChaCha20Poly1305\verify($key, $nonce, $aad, $plaintext, $tag);

```

The `Context` object maintains the current state of all of the moving parts so they can be used for streaming. A separate context is needed for each stream.

*Stream methods*

```
$cipher = new \ChaCha20Poly1305\Cipher;
$encCtx = $cipher->init($key, $nonce);

$cipher->aad($encCtx, $additionalData);
$cipher->aad($encCtx, $moreData);

$ciphertext = $cipher->encrypt($encCtx, $plaintext);
$ciphertext .= $cipher->encrypt($encCtx, $morePlaintext);

$tag = $cipher->finish($encCtx);

// Or

$cipher = new \ChaCha20Poly1305\Cipher;
$decCtx = $cipher->init($key, $nonce);

$cipher->aad($decCtx, $additionalData);
$cipher->aad($decCtx, $moreData);

// Could also $cipher->verify() to skip decryption overhead.
$plaintext = $cipher->decrypt($decCtx, $ciphertext);
$plaintext .= $cipher->decrypt($decCtx, $moreCiphertext);

try {
    $cipher->finish($decCtx, $tag);
}
catch (\ChaCha20Poly1305\AuthenticationException $e) {
    // Tag was not valid
}

```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% 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 ~23 days

Total

3

Last Release

3798d ago

PHP version history (2 changes)0.1.0PHP &gt;=5.4

0.2.0PHP &gt;=7.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1503065?v=4)[lt](/maintainers/lt)[@lt](https://github.com/lt)

---

Top Contributors

[![lt](https://avatars.githubusercontent.com/u/1503065?v=4)](https://github.com/lt "lt (6 commits)")[![dmaixner](https://avatars.githubusercontent.com/u/3341984?v=4)](https://github.com/dmaixner "dmaixner (2 commits)")[![8u](https://avatars.githubusercontent.com/u/7874359?v=4)](https://github.com/8u "8u (1 commits)")

---

Tags

securityencryptionAuthenticationaeadcipherMACauthenticated

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/leigh-aead-chacha20-poly1305/health.svg)

```
[![Health](https://phpackages.com/badges/leigh-aead-chacha20-poly1305/health.svg)](https://phpackages.com/packages/leigh-aead-chacha20-poly1305)
```

###  Alternatives

[paragonie/sodium_compat

Pure PHP implementation of libsodium; uses the PHP extension if it exists

931141.1M172](/packages/paragonie-sodium-compat)[hwi/oauth-bundle

Support for authenticating users using both OAuth1.0a and OAuth2 in Symfony.

2.4k22.0M76](/packages/hwi-oauth-bundle)[lusitanian/oauth

PHP 7.2 oAuth 1/2 Library

1.1k23.7M130](/packages/lusitanian-oauth)[scheb/2fa

Two-factor authentication for Symfony applications (please use scheb/2fa-bundle to install)

585665.9k1](/packages/scheb-2fa)[delight-im/auth

Authentication for PHP. Simple, lightweight and secure.

1.2k142.4k30](/packages/delight-im-auth)[virgil/crypto

Virgil is a stack of security libraries (ECIES with Crypto Agility wrapped in Virgil Cryptogram) and all the necessary infrastructure to enable seamless, end-to-end encryption for any application, platform or device. See below for currently available languages and platforms. Get in touch with us to get preview access to our key infrastructure.

3318.9k2](/packages/virgil-crypto)

PHPackages © 2026

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