PHPackages                             ezimuel/phpcrypto - 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. ezimuel/phpcrypto

ActiveLibrary[Security](/categories/security)

ezimuel/phpcrypto
=================

Cryptographic library for PHP 7 based on OpenSSL

1218.7k↓37.5%4PHP

Since Apr 8Pushed 10y ago1 watchersCompare

[ Source](https://github.com/ezimuel/phpcrypto)[ Packagist](https://packagist.org/packages/ezimuel/phpcrypto)[ RSS](/packages/ezimuel-phpcrypto/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHPCrypto
=========

[](#phpcrypto)

[![Build Status](https://camo.githubusercontent.com/d0765ab2602f874b673ce1f350360e49d791b97228abfb55ff6ed9de48e1a861/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f657a696d75656c2f70687063727970746f2e7376673f6272616e63683d6d6173746572)](https://secure.travis-ci.org/ezimuel/phpcrypto)

About
-----

[](#about)

This is a cryptography library for PHP 7. It's based on [OpenSSL](http://php.net/manual/en/book.openssl.php) and provides the following features:

- Symmetric encryption and authentication (AES + HMAC-SHA256 as default);
- Public Key cryptography (management keys, encryption/decryption)
- Hybrid encryption using symmetric and public key ([OpenPGP](http://www.ietf.org/rfc/rfc4880.txt) like)

Version
-------

[](#version)

As this software is **ALPHA, Use at your own risk!**

Usage
-----

[](#usage)

The usage is quite straightforward, after installing the library using composer:

```
composer require ezimuel/phpcrypto:dev-master

```

You can consume the following classes Symmetric, PublicKey and Hybrid for symmetric encryption, public key and hybrid encryption.

For instance, if you want to encrypt a string in a symmetric way, you can use the following code:

```
use PHPCrypto\Symmetric;

$plaintext = 'Text to encrypt';
$key = '123456789012'; // This can be also a user's password we generate a new
                       // one for encryption using PBKDF2 algorithm

$cipher = new Symmetric(); // AES + HMAC-SHA256 by default
$cipher->setKey($key);
$ciphertext = $cipher->encrypt($plaintext);

// or passing the $key as optional paramter
// $ciphertext = $cipher->encrypt($plaintext, $key);

$result = $cipher->decrypt($ciphertext);

// or passing the $key as optional paramter
// $result = $cipher->decrypt($ciphertext, $key);

print ($result === $plaintext) ? "OK" : "FAILURE";
```

SECURITY BEST PRACTICES
-----------------------

[](#security-best-practices)

In this project we used the following security best practices:

- Min size of user's key for encryption set to 12

    Source: [https://en.wikipedia.org/wiki/Password\_strength](https://en.wikipedia.org/wiki/Password_strength)
- Use of PBKDF2 to generate the encryption and authentication key. Set the default iteration number to 80'000 (min 20'000)

    Source:
- Encryption-then-authentication using HMAC

    Source:
- Use of OAEP padding for OpenSSL public key encryption

    Source:

TO DO
-----

[](#to-do)

- encrypt/decrypt functions in PublicKey
- sign/verify functions for digital signature in PublicKey
- support multiple keys in Hybrid schema
- Ca management in public key schemas

NOTES ABOUT OPENSSL EXTENSION
-----------------------------

[](#notes-about-openssl-extension)

Here I reported some notes about the OpenSSL PHP extension usage:

- it will be nice to have the **openssl\_cipher\_key\_size()** function to get the key size of the specific cipher choosen;

Copyright
---------

[](#copyright)

Copyright 2016 by [Enrico Zimuel](http://www.zimuel.it)

The license usage is reported in the [LICENSE](LICENSE) file.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.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/75c7c511421feb14316a01d29a7566bd4fdd97147b5a4f3faa5a065f9d0a0193?d=identicon)[ezimuel](/maintainers/ezimuel)

---

Top Contributors

[![ezimuel](https://avatars.githubusercontent.com/u/475967?v=4)](https://github.com/ezimuel "ezimuel (21 commits)")[![paragonie-scott](https://avatars.githubusercontent.com/u/11591518?v=4)](https://github.com/paragonie-scott "paragonie-scott (1 commits)")

### Embed Badge

![Health badge](/badges/ezimuel-phpcrypto/health.svg)

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

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