PHPackages                             nabeghe/simple-cipher - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. nabeghe/simple-cipher

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

nabeghe/simple-cipher
=====================

A simple cipher using OpenSSL with a few additional tweaks.

1.0.0(1y ago)412MITPHPPHP &gt;=7.4

Since Oct 19Pushed 10mo ago1 watchersCompare

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

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

Simple Cipher for PHP ≥ 7.4
===========================

[](#simple-cipher-for-php--74)

> A simple cipher using OpenSSL with a few additional tweaks.

Implementing a cipher to encrypt and decrypt your data can be a bit tricky, but with OpenSSL, it's a breeze. However, this library combines several techniques to give you a simple yet effective way to handle encryption and decryption. You don’t even need to set a secret or password for your cipher system! If you don’t specify one, a default value is used that’s unique and remains constant throughout the program, except in special cases. However, it's not recommended

The best part? You'll be working with a SimpleCipher class here, where its methods are accessible both statically and through object instances. Data is returned in the same type it was encrypted with, ensuring consistency. but objects converted into arrays, and you also have the option to set a default value in case there’s an issue with decryption.

🫡 Usage
-------

[](#-usage)

### 🚀 Installation

[](#-installation)

You can install the package via composer:

```
composer require nabeghe/simple-cipher
```

### Configuration

[](#configuration)

The configuration can be an array, string, number, or null. A string or number means setting the secret (password), null means using default values, and an array allows for setting each option separately.

#### Array Syntax:

[](#array-syntax)

Optiona nameDescriptionalgoThe cipher method.
Default: aes-256-gcmsecretThe cipher secret (password).
Default: A random value is generated at the start &amp; stored in a file within the library's directory. However, the priority is first given to a constant named `SIMPLE_CIPHER_SECRET`, , and then to an environment key with the same name in `$_ENV`.defaultA default value is used in case there’s an issue in the decryption process, which is null if not set.### Static Mode

[](#static-mode)

#### Syntax:

[](#syntax)

```
SimpleCipher::encrypt(mixed $data, array|string|int|null $config): string;

SimpleCipher::decrypt(string $data, array|string|int|null $config): mixed;
```

#### Example:

[](#example)

```
use Nabeghe\SimpleCipher\SimpleCipher;

$data = 'nabeghe/simple-cipher';

$encrypted = SimpleCipher::encrypt($data, 'YOUR_SECRET');
echo "Encrypted Data:\n";
echo "$encrypted\n\n";

$decrypted = SimpleCipher::decrypt($encrypted, 'YOUR_SECRET');
echo "Decrypted Data:\n";
var_dump($decrypted);
```

### Instance Mode

[](#instance-mode)

#### Syntax:

[](#syntax-1)

```
__construct(array|string|int|null $config = null)

$cipher->encrypt(mixed $data): string;

$cipher->decrypt(string $data, mixed $default = null): mixed;
```

#### Example:

[](#example-1)

```
use Nabeghe\SimpleCipher\SimpleCipher;

$data = 'nabeghe/simple-cipher';

$cipher = new SimpleCipher('YOUR_SECRET');

$encrypted = $cipher->encrypt($data);
echo "Encrypted Data:\n";
echo "$encrypted\n\n";

$decrypted = $cipher->decrypt($encrypted);
echo "Decrypted Data:\n";
var_dump($decrypted);
```

📖 License
---------

[](#-license)

Licensed under the MIT license, see [LICENSE.md](LICENSE.md) for details.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance46

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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

576d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dae1bf378bcf40fe55c193160377d613d628188587554a3fb11cdec6f0521ba1?d=identicon)[nabeghe](/maintainers/nabeghe)

---

Top Contributors

[![nabeghe](https://avatars.githubusercontent.com/u/12207627?v=4)](https://github.com/nabeghe "nabeghe (3 commits)")

---

Tags

ciphercipher-algorithmsopensslopenssl-toolsphpphp-libraryphplibrarysecurityhelpersecurityencryptionpasswordlibraryencryptopensslciphersupportsecretdecryptiondecryot

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nabeghe-simple-cipher/health.svg)

```
[![Health](https://phpackages.com/badges/nabeghe-simple-cipher/health.svg)](https://phpackages.com/packages/nabeghe-simple-cipher)
```

###  Alternatives

[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[poly-crypto/poly-crypto

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

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

PHPackages © 2026

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