PHPackages                             dbublik/cryptography - 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. dbublik/cryptography

ActiveLibrary[Security](/categories/security)

dbublik/cryptography
====================

A lightweight cryptography library for string encryption and decryption

v1.0.1(1y ago)00[3 PRs](https://github.com/dbublik/cryptography/pulls)MITPHPPHP ^8.2CI passing

Since Mar 10Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/dbublik/cryptography)[ Packagist](https://packagist.org/packages/dbublik/cryptography)[ RSS](/packages/dbublik-cryptography/feed)WikiDiscussions main Synced 1mo ago

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

Cryptography
============

[](#cryptography)

[![PHP Version Requirement](https://camo.githubusercontent.com/d82858ee62032c812454c98d66a4bafb3aee613ed74b89bc7bdd4850ccfaa635/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f646275626c696b2f63727970746f6772617068792f706870)](https://packagist.org/packages/dbublik/cryptography)[![License](https://camo.githubusercontent.com/e0bcc07bbde5b15499cc049bbe4b61114ccc5913d2645f8c941f5a9d43fee1ab/68747470733a2f2f706f7365722e707567782e6f72672f646275626c696b2f63727970746f6772617068792f6c6963656e7365)](https://choosealicense.com/licenses/mit/)[![Tests](https://github.com/dbublik/cryptography/actions/workflows/tests.yaml/badge.svg)](https://github.com/dbublik/cryptography/actions/workflows/tests.yaml)[![Lint](https://github.com/dbublik/cryptography/actions/workflows/lint.yaml/badge.svg)](https://github.com/dbublik/cryptography/actions/workflows/lint.yaml)[![Code coverage](https://camo.githubusercontent.com/979b3cc9c9f04a338f58f573c02499255793dd018131ae6ec89608110d6eae55/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f646275626c696b2f63727970746f6772617068792f62616467652e737667)](https://coveralls.io/github/dbublik/cryptography)[![Mutation score](https://camo.githubusercontent.com/e50c17ef1c9544d47fba58febf76f1a5f1c64b8ecfba637680a00b0364d1a3d5/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d253246646275626c696b25324663727970746f6772617068792532466d61696e)](https://dashboard.stryker-mutator.io/reports/github.com/dbublik/cryptography/main)

Need to encrypt and decrypt strings effortlessly? Encrypter does it for you with just two simple methods.

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

[](#installation)

```
composer require dbublik/cryptography
```

Usage
-----

[](#usage)

### Initialize encrypter:

[](#initialize-encrypter)

```
use DBublik\Cryptography\Encrypter;

$secretKey = 'your_secret_key';
$encrypter = Encrypter::create($secretKey);
```

or prepare it for a container, e.g. for Symfony:

```
// config/services.php

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use DBublik\Cryptography\Encrypter;

return function(ContainerConfigurator $container): void {
    $services = $container->services();

    $services->set(Encrypter::class)
        ->factory([null, 'create'])
        ->args([env('YOUR_SECRET_KEY')]);
};
```

Available encryption algorithms: `aes-128-gcm`, `aes-192-gcm` and `aes-256-gcm` (by default).

### Encrypt:

[](#encrypt)

```
final readonly class ExampleService
{
    public function __construct(
        private \DBublik\Cryptography\Encrypter $encrypter,
    ) {}

    public function save(#[\SensitiveParameter] string $sensitiveValue): void
    {
        $encryptedValue = $this->encrypter->encrypt($sensitiveValue);

        // Don't forget to save $encryptedValue somewhere
    }
}
```

### Decrypt:

[](#decrypt)

```
final readonly class ExampleService
{
    public function __construct(
        private \DBublik\Cryptography\Encrypter $encrypter,
    ) {}

    public function doSomething(string $encryptedValue): mixed
    {
        $sensitiveValue = $this->encrypter->decrypt($encryptedValue);

        // Be careful! Do not show $sensitiveValue to anyone
    }
}
```

Supported PHP versions
----------------------

[](#supported-php-versions)

PHP 8.2 and later.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance63

Regular maintenance activity

Popularity0

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 84.6% 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 ~0 days

Total

2

Last Release

434d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b0b6e030e23ca656f23ec0238ab511d67d8eb21d5a4376e80f66cccf889313a8?d=identicon)[dbublik](/maintainers/dbublik)

---

Top Contributors

[![dbublik](https://avatars.githubusercontent.com/u/17051937?v=4)](https://github.com/dbublik "dbublik (11 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

---

Tags

decryptionencryptionphpsecurity

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dbublik-cryptography/health.svg)

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

###  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)
