PHPackages                             bayfrontmedia/encryptor - 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. bayfrontmedia/encryptor

ActiveLibrary[Security](/categories/security)

bayfrontmedia/encryptor
=======================

A fast, simple two-way encryption library utilizing OpenSSL.

v2.0.1(1y ago)18303MITPHPPHP ^8.0

Since Aug 28Pushed 1y ago1 watchersCompare

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

READMEChangelog (4)DependenciesVersions (5)Used By (3)

Encryptor
---------

[](#encryptor)

A fast, simple two-way encryption library utilizing OpenSSL.

- [License](#license)
- [Author](#author)
- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)

License
-------

[](#license)

This project is open source and available under the [MIT License](LICENSE).

Author
------

[](#author)

[![Bayfront Media](https://camo.githubusercontent.com/0c0163913b2092e97dbf9684970adaf86f2f25871298d3d28b2dff4bf75b2915/68747470733a2f2f63646e312e6f6e62617966726f6e742e636f6d2f62666d2f6272616e642f62666d2d6c6f676f2e737667)](https://camo.githubusercontent.com/0c0163913b2092e97dbf9684970adaf86f2f25871298d3d28b2dff4bf75b2915/68747470733a2f2f63646e312e6f6e62617966726f6e742e636f6d2f62666d2f6272616e642f62666d2d6c6f676f2e737667)

- [Bayfront Media homepage](https://www.bayfrontmedia.com?utm_source=github&utm_medium=direct)
- [Bayfront Media GitHub](https://github.com/bayfrontmedia)

Requirements
------------

[](#requirements)

- PHP `^8.0` (Tested up to `8.4`)
- OpenSSL PHP extension
- JSON PHP extension

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

[](#installation)

```
composer require bayfrontmedia/encryptor

```

Usage
-----

[](#usage)

### Start using Encryptor

[](#start-using-encryptor)

A private, reproducible key must be passed to the constructor. The same key must be used when encrypting and decrypting. If the key used to encrypt a value is lost, it will not be able to be decrypted.

An optional second constructor parameter allows you to specify which [cipher method](https://www.php.net/manual/en/function.openssl-get-cipher-methods.php) to use. By default, Encryptor uses `AES-256-CBC`.

If an invalid cipher method is used, a `Bayfront\Encryptor\InvalidCipherException` exception will be thrown.

```
use Bayfront\Encryptor\Encryptor;

$encryptor = new Encryptor('private_key');

```

### Public methods

[](#public-methods)

- [getKey](#getkey)
- [getCipher](#getcipher)
- [encrypt](#encrypt)
- [encryptString](#encryptstring)
- [decrypt](#decrypt)
- [decryptString](#decryptstring)

---

### getKey

[](#getkey)

**Description:**

Returns the encryption key.

**Parameters:**

- None

**Returns:**

- (string)

---

### getCipher

[](#getcipher)

**Description:**

Returns the cipher method used for encryption.

**Parameters:**

- None

**Returns:**

- (string)

---

### encrypt

[](#encrypt)

**Description:**

Encrypts a given value.

**Parameters:**

- `$value` (mixed)
- `$serialize = true` (bool)

**Returns:**

- (string)

**Throws:**

- `Bayfront\Encryptor\EncryptException`

**Example:**

```
try {

    $encrypted = $encryptor->encrypt([
        'name' => 'John',
        'user_id' => 8
    ]);

} catch (EncryptException $e) {
    die($e->getMessage());
}

```

---

### encryptString

[](#encryptstring)

**Description:**

Encrypts a string without serialization.

**Parameters:**

- `$value` (string)

**Returns:**

- (string)

**Throws:**

- `Bayfront\Encryptor\EncryptException`

**Example:**

```
try {

    $encrypted_string = $encryptor->encryptString('A string to encrypt');

} catch (EncryptException $e) {
    die($e->getMessage());
}

```

---

### decrypt

[](#decrypt)

**Description:**

Decrypts a given value.

**Parameters:**

- `$data` (string)
- `$unserialize = true` (bool)

**Returns:**

- (mixed)

**Throws:**

- `Bayfront\Encryptor\DecryptException`

**Example:**

```
try {

    $decrypted = $encryptor->decrypt($encrypted);

} catch (DecryptException $e) {
    die($e->getMessage());
}

```

---

### decryptString

[](#decryptstring)

**Description:**

Decrypts a string without unserialization.

**Parameters:**

- `$data` (string)

**Returns:**

- (string)

**Throws:**

- `Bayfront\Encryptor\DecryptException`

**Example:**

```
try {

    $decrypted_string = $encryptor->decryptString($encrypted_string);

} catch (DecryptException $e) {
    die($e->getMessage());
}

```

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance40

Moderate activity, may be stable

Popularity15

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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 ~526 days

Total

4

Last Release

509d ago

Major Versions

v1.0.1 → v2.0.02023-01-26

PHP version history (2 changes)1.0.0PHP &gt;=7.1.0

v2.0.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/5ad62c8d0e69358fd63b16fdaa71d5359231cd0cf660bbc3419071dc705c63a8?d=identicon)[bayfrontmedia](/maintainers/bayfrontmedia)

---

Top Contributors

[![robinsonjohn](https://avatars.githubusercontent.com/u/24327848?v=4)](https://github.com/robinsonjohn "robinsonjohn (12 commits)")

---

Tags

decryptdecryptionencryptencryptionencryptoropensslphpphpencryptionencryptdecryptopenssldecryptionencryptor

### Embed Badge

![Health badge](/badges/bayfrontmedia-encryptor/health.svg)

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

###  Alternatives

[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

961.0M2](/packages/nzo-url-encryptor-bundle)[poly-crypto/poly-crypto

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

127.8k1](/packages/poly-crypto-poly-crypto)[hemiframe/php-aes

PHP class for encrypt and decrypt data with AES algorithm

1030.3k](/packages/hemiframe-php-aes)

PHPackages © 2026

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