PHPackages                             dsbaars/chacha20 - 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. dsbaars/chacha20

ActiveLibrary[Security](/categories/security)

dsbaars/chacha20
================

Pure PHP implementation of the ChaCha20 encryption algorithm.

0.3.0(7mo ago)18.6k—8.3%1MITPHPPHP &gt;=8.1CI passing

Since Dec 14Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/dsbaars/PHP-ChaCha20)[ Packagist](https://packagist.org/packages/dsbaars/chacha20)[ Docs](https://github.com/dsbaars/PHP-ChaCha20)[ RSS](/packages/dsbaars-chacha20/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (3)Versions (5)Used By (1)

[![CI](https://github.com/dsbaars/PHP-ChaCha20/actions/workflows/ci.yml/badge.svg)](https://github.com/dsbaars/PHP-ChaCha20/actions/workflows/ci.yml)[![Packagist PHP Version](https://camo.githubusercontent.com/03f3af02ea96dfff48d9aee0ec80e4e0bb136bcb1af2fafc591417db4240b072/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f647362616172732f5048502d43686143686132302f706870)](https://camo.githubusercontent.com/03f3af02ea96dfff48d9aee0ec80e4e0bb136bcb1af2fafc591417db4240b072/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f647362616172732f5048502d43686143686132302f706870)

ChaCha20 in PHP
===============

[](#chacha20-in-php)

Fork of [leigh/chacha20](https://github.com/lt/PHP-ChaCha20)

This library contains a pure PHP implementation of the ChaCha20 encryption algorithm.

The library has been written to be high performance (relative to PHP), not pretty. It obviously doesn't perform anywhere close to a native implementation.

### Usage:

[](#usage)

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

```
$chacha20 = new ChaCha20\Cipher;
$encCtx = $chacha20->init($key, $nonce);
$decCtx = $chacha20->init($key, $nonce);

$cipherText = $chacha20->encrypt($encCtx, $message);
$plainText = $chacha20->decrypt($decCtx, $cipherText);

```

The `Context` object maintains the current state of the algorithm, so that it can be used in a streaming scenario. Therefore an application performing simultaneous encryption and decryption will need to main two contexts.

The `decrypt` method is an alias of the `encrypt` method, and exists only to indicate intent.

Seek operations can be performed on the keystream by calling the `setCounter` method, where the count is in 64-byte blocks.

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance64

Regular maintenance activity

Popularity27

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 69.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 ~1212 days

Total

4

Last Release

217d ago

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

0.2.0PHP &gt;=7.0

0.3.0PHP &gt;=8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/480514?v=4)[Djuri Baars](/maintainers/dsbaars)[@dsbaars](https://github.com/dsbaars)

---

Top Contributors

[![lt](https://avatars.githubusercontent.com/u/1503065?v=4)](https://github.com/lt "lt (18 commits)")[![dsbaars](https://avatars.githubusercontent.com/u/480514?v=4)](https://github.com/dsbaars "dsbaars (8 commits)")

---

Tags

streamsecurityencryptioncipher

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dsbaars-chacha20/health.svg)

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

###  Alternatives

[defuse/php-encryption

Secure PHP Encryption Library

3.9k175.2M254](/packages/defuse-php-encryption)[phpseclib/phpseclib

PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.

5.6k465.6M1.5k](/packages/phpseclib-phpseclib)[ass/xmlsecurity

The XmlSecurity library is written in PHP for working with XML Encryption and Signatures

955.7M35](/packages/ass-xmlsecurity)[nzo/url-encryptor-bundle

The NzoUrlEncryptorBundle is a Symfony Bundle used to Encrypt and Decrypt data and variables in the Web application or passed through URL

971.1M2](/packages/nzo-url-encryptor-bundle)[tilleuls/url-signer-bundle

Create and validate signed URLs with a limited lifetime in Symfony

81369.3k](/packages/tilleuls-url-signer-bundle)[ercsctt/laravel-file-encryption

Secure file encryption and decryption for Laravel applications

778.3k1](/packages/ercsctt-laravel-file-encryption)

PHPackages © 2026

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