PHPackages                             smoren/encryption-tools - 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. smoren/encryption-tools

ActiveLibrary[Security](/categories/security)

smoren/encryption-tools
=======================

Tools for encryption/decryption and signing/verifying (wraps openssl lib)

1.0.0(4y ago)13531MITPHPPHP &gt;=7.2.0

Since Aug 11Pushed 2y ago5 watchersCompare

[ Source](https://github.com/Smoren/encryption-tools-php)[ Packagist](https://packagist.org/packages/smoren/encryption-tools)[ RSS](/packages/smoren-encryption-tools/feed)WikiDiscussions master Synced today

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

encryption-tools
================

[](#encryption-tools)

[![Packagist PHP Version Support](https://camo.githubusercontent.com/f9a3c27aaae9c5260fa353f3aacb72baa78ef3c22d4b64613ad64d320a9213ed/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f736d6f72656e2f656e6372797074696f6e2d746f6f6c73)](https://camo.githubusercontent.com/f9a3c27aaae9c5260fa353f3aacb72baa78ef3c22d4b64613ad64d320a9213ed/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f736d6f72656e2f656e6372797074696f6e2d746f6f6c73)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/37fccff7fbabcbe61582c3554ed303351c60c495c551ca77eb16331647ef1126/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f536d6f72656e2f656e6372797074696f6e2d746f6f6c732d7068702f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Smoren/encryption-tools-php/?branch=master)[![Coverage Status](https://camo.githubusercontent.com/cc390d3c04ad0ec371ccfe447feb0f2db41e7fb203c1a798b9d802c6b02d5fe2/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f536d6f72656e2f656e6372797074696f6e2d746f6f6c732d7068702f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/Smoren/encryption-tools-php?branch=master)[![Build and test](https://github.com/Smoren/encryption-tools-php/actions/workflows/test_master.yml/badge.svg)](https://github.com/Smoren/encryption-tools-php/actions/workflows/test_master.yml/badge.svg)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)

Tools for encryption/decryption and signing/verifying (wraps openssl lib).

- Symmetric
- Asymmetric (RSA-based)

### Install to your project

[](#install-to-your-project)

```
composer require smoren/encryption-tools
```

### Unit testing

[](#unit-testing)

```
composer install
composer test-init
composer test
```

### Usage

[](#usage)

#### Symmetric encryption/decryption

[](#symmetric-encryptiondecryption)

```
use Smoren\EncryptionTools\Helpers\SymmetricEncryptionHelper;

$data = ["some", "data" => "to", "encrypt"];
$secretKey = uniqid();

$dataEncrypted = SymmetricEncryptionHelper::encrypt($data, $secretKey);
$dataDecrypted = SymmetricEncryptionHelper::decrypt($dataEncrypted, $secretKey);
print_r($dataDecrypted);

$dataEncrypted = SymmetricEncryptionHelper::encrypt($data, $secretKey, 'camellia-256-ofb');
$dataDecrypted = SymmetricEncryptionHelper::decrypt($dataEncrypted, $secretKey, 'camellia-256-ofb');
print_r($dataDecrypted);
```

#### Asymmetric encryption/decryption (RSA-based)

[](#asymmetric-encryptiondecryption-rsa-based)

```
use Smoren\EncryptionTools\Helpers\AsymmetricEncryptionHelper;

$data = ["some", "data" => "to", "encrypt"];
[$privateKey, $publicKey] = AsymmetricEncryptionHelper::generateKeyPair();

$dataEncrypted = AsymmetricEncryptionHelper::encryptByPrivateKey($data, $privateKey);
$dataDecrypted = AsymmetricEncryptionHelper::decryptByPublicKey($dataEncrypted, $publicKey);
print_r($dataDecrypted);

$dataEncrypted = AsymmetricEncryptionHelper::encryptByPublicKey($data, $publicKey);
$dataDecrypted = AsymmetricEncryptionHelper::decryptByPrivateKey($dataEncrypted, $privateKey);
print_r($dataDecrypted);
```

#### Asymmetric signing/verifying (RSA-based)

[](#asymmetric-signingverifying-rsa-based)

```
use Smoren\EncryptionTools\Helpers\AsymmetricEncryptionHelper;
use Smoren\EncryptionTools\Exceptions\AsymmetricEncryptionException;

$data = ["some", "data" => "to", "encrypt"];
[$privateKey, $publicKey] = AsymmetricEncryptionHelper::generateKeyPair();

$signature = AsymmetricEncryptionHelper::sign($data, $privateKey);

try {
    AsymmetricEncryptionHelper::verify($data, $signature, $publicKey);
} catch(AsymmetricEncryptionException $e) {
    // ... handling exception if cannot verify signature
}
```

#### Asymmetric encryption/decryption (RSA-based) for large data

[](#asymmetric-encryptiondecryption-rsa-based-for-large-data)

```
use Smoren\EncryptionTools\Helpers\AsymmetricLargeDataEncryptionHelper;

$data = file_get_contents('file_with_large_data.txt');
[$privateKey, $publicKey] = AsymmetricLargeDataEncryptionHelper::generateKeyPair();

$dataEncrypted = AsymmetricLargeDataEncryptionHelper::encryptByPrivateKey($data, $privateKey);
$dataDecrypted = AsymmetricLargeDataEncryptionHelper::decryptByPublicKey($dataEncrypted, $publicKey);
print_r($dataDecrypted);

$dataEncrypted = AsymmetricLargeDataEncryptionHelper::encryptByPublicKey($data, $publicKey);
$dataDecrypted = AsymmetricLargeDataEncryptionHelper::decryptByPrivateKey($dataEncrypted, $privateKey);
print_r($dataDecrypted);
```

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

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

Unknown

Total

1

Last Release

1786d ago

### Community

Maintainers

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

---

Top Contributors

[![Smoren](https://avatars.githubusercontent.com/u/7403235?v=4)](https://github.com/Smoren "Smoren (27 commits)")

---

Tags

cryptographyencryptionrsasecurityencryptionrsaencryptdecryptopenssldecryption

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/smoren-encryption-tools/health.svg)

```
[![Health](https://phpackages.com/badges/smoren-encryption-tools/health.svg)](https://phpackages.com/packages/smoren-encryption-tools)
```

###  Alternatives

[defuse/php-encryption

Secure PHP Encryption Library

3.9k175.2M254](/packages/defuse-php-encryption)[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)[miladrahimi/phpcrypt

Encryption, decryption, and hashing tools for PHP projects

3275.4k2](/packages/miladrahimi-phpcrypt)[poly-crypto/poly-crypto

High-level cryptographic functions that are interoperable between NodeJS and PHP 7.1+

128.1k1](/packages/poly-crypto-poly-crypto)

PHPackages © 2026

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