PHPackages                             elavrom/cryptor - 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. elavrom/cryptor

ActiveLibrary[Security](/categories/security)

elavrom/cryptor
===============

A simple helper class for encryption, decryption, and hmac signing.

0.3.0(4y ago)08.6k—5%MITPHPPHP ^7.4||^8.0

Since Mar 19Pushed 4y ago1 watchersCompare

[ Source](https://github.com/elavrom/cryptor)[ Packagist](https://packagist.org/packages/elavrom/cryptor)[ RSS](/packages/elavrom-cryptor/feed)WikiDiscussions main Synced 2w ago

READMEChangelogDependencies (1)Versions (7)Used By (0)

Cryptor
=======

[](#cryptor)

A simple helper class for encryption, decryption, and hmac signing.

---

Get Started
-----------

[](#get-started)

For the first instantiation, you have to provide two secret keys that will be your passphrases.

It is recommended that you generate your own secret keys to encrypt and sign data, and keep it safe. A way of generating this kind of secret key is to use OpenSSL :

```
# Hexadecimal doubles the number of bytes
# so that would be a 64 bytes long passphrase
openssl rand -hex 32
```

Examples
--------

[](#examples)

### Encryption / Decryption

[](#encryption--decryption)

```
$cryptor = new Cryptor($_ENV['MY_ENCRYPTION_SECRET'], $_ENV['MY_SIGNING_SECRET']);
$myData = '{"a": "This is a sample value."}';

$encrypted = $cryptor->encrypt($myData);
$decrypted = $cryptor->decrypt($encrypted);

// If you don't want to use default cipher method, or default secret, you can override them :
$encrypted = $cryptor->encrypt($myData, null, 'aes-128-cbc');
$encrypted = $cryptor->decrypt($encrypted, null, 'aes-128-cbc');

$encrypted = $cryptor->encrypt($myData, 'myCustomKey', null);
$encrypted = $cryptor->decrypt($encrypted, 'myCustomKey', null);

// You can get URL safe base64 result with the last argument :
$encrypted = $cryptor->encrypt($myData, null, null, true);
```

### HMAC Signing / Checking

[](#hmac-signing--checking)

```
$cryptor = new Cryptor($_ENV['MY_ENCRYPTION_SECRET'], $_ENV['MY_SIGNING_SECRET']);
$myData = '{"a": "This is a sample value."}';

// You can simply sign your data with :
$signature = $cryptor->sign($myData);
// And check if a signature originated from you with :
$valid = $cryptor->checkSignature($signature, $myData);
// You can also sign a file directly. Cryptor checks if the file exists and is readable :
$signature = $cryptor->sign('/path/to/my/file.txt');

// Same as encryption, you can override the secret and the hash algorithm :
$signature = $cryptor->sign($myData, 'myCustomSecret', null);
$valid = $cryptor->checkSignature($signature, $myData, 'myCustomSecret', null);

$signature = $cryptor->sign($myData, null, 'sha384');
$valid = $cryptor->checkSignature($signature, $myData, null, 'sha384');
```

###  Health Score

28

—

LowBetter than 51% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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

Every ~8 days

Total

6

Last Release

1574d ago

PHP version history (2 changes)0.1.0PHP ^8.0

0.1.1PHP ^7.4||^8.0

### Community

Maintainers

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

---

Top Contributors

[![elavrom](https://avatars.githubusercontent.com/u/16175245?v=4)](https://github.com/elavrom "elavrom (16 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/elavrom-cryptor/health.svg)

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

###  Alternatives

[phpids/phpids

PHPIDS (PHP-Intrusion Detection System) is a simple to use, well structured, fast and state-of-the-art security layer for your PHP based web application

791150.0k2](/packages/phpids-phpids)[paragonie/ecc

PHP Elliptic Curve Cryptography library

25866.3k44](/packages/paragonie-ecc)[sansec/magento2-module-shield

15218.6k](/packages/sansec-magento2-module-shield)[nicobleiler/php-passphrase

Passphrase generator with Laravel integration, inspired by Bitwarden. Uses the EFF long word list by default with support for custom wordlists.

4912.6k](/packages/nicobleiler-php-passphrase)[dwgebler/encryption

Encryption wrapper for PHP using libsodium — simple API for symmetric and asymmetric encryption, password hashing, digital signing, and message authentication.

317.5k](/packages/dwgebler-encryption)

PHPackages © 2026

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