PHPackages                             limb-php/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. [Security](/categories/security)
4. /
5. limb-php/aead-chacha20-poly1305

ActiveLibrary[Security](/categories/security)

limb-php/aead-chacha20-poly1305
===============================

RFC 8439 ChaCha20/Poly1305 AEAD construction

01PHP

Since Mar 11Pushed 1mo agoCompare

[ Source](https://github.com/limb-php/PHP-AEAD-ChaCha20-Poly1305)[ Packagist](https://packagist.org/packages/limb-php/aead-chacha20-poly1305)[ RSS](/packages/limb-php-aead-chacha20-poly1305/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

RFC 8439 ChaCha20/Poly1305 AEAD construction
============================================

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

This library contains a pure PHP implementation of the RFC 8439 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

21

—

LowBetter than 19% of packages

Maintenance62

Regular maintenance activity

Popularity2

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 54.5% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/78afb8404330170e30bb86cfbd8018b28359ea61cd8d161a3a6e09b274a8a4f5?d=identicon)[xadminx](/maintainers/xadminx)

---

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)")[![xadminx](https://avatars.githubusercontent.com/u/399028?v=4)](https://github.com/xadminx "xadminx (2 commits)")[![8u](https://avatars.githubusercontent.com/u/7874359?v=4)](https://github.com/8u "8u (1 commits)")

### Embed Badge

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

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

###  Alternatives

[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M212](/packages/defuse-php-encryption)[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.7M112](/packages/mews-purifier)[robrichards/xmlseclibs

A PHP library for XML Security

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

Realistic password strength estimation PHP library based on Zxcvbn JS

86917.5M63](/packages/bjeavons-zxcvbn-php)[enlightn/security-checker

A PHP dependency vulnerabilities scanner based on the Security Advisories Database.

33732.2M110](/packages/enlightn-security-checker)

PHPackages © 2026

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