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.4k↓17.9%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 2d 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

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

1529d 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

[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k18.7M143](/packages/mews-purifier)[paragonie/ecc

PHP Elliptic Curve Cryptography library

24820.0k38](/packages/paragonie-ecc)[laravelgems/blade-escape

Custom blade directives to figth against XSS

1212.5k](/packages/laravelgems-blade-escape)

PHPackages © 2026

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