PHPackages                             manojx/encrypter-bundle - 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. manojx/encrypter-bundle

ActiveSymfony-bundle[Security](/categories/security)

manojx/encrypter-bundle
=======================

A Symfony bundle to encrypt and decrypt data using AES-256-CBC encryption.

1.0.2(1y ago)1782[1 issues](https://github.com/ManojBitx/encrypter-bundle/issues)MITPHPPHP ^7.4 || ^8.0

Since Oct 5Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ManojBitx/encrypter-bundle)[ Packagist](https://packagist.org/packages/manojx/encrypter-bundle)[ RSS](/packages/manojx-encrypter-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

Encrypter Symfony Bundle
========================

[](#encrypter-symfony-bundle)

Purpose
-------

[](#purpose)

The Encrypter Bundle provides a simple and secure way to encrypt and decrypt data using the AES-256-CBC encryption algorithm. This bundle is designed for Symfony applications, allowing developers to protect sensitive information with ease. With built-in support for key generation and salt handling, the Encrypter Bundle helps ensure that your data remains secure.

Features
--------

[](#features)

- **Secure Encryption**: Uses AES-256-CBC for data protection.
- **Key Management**: Supports random key and salt generation.
- **Easy Integration**: Seamlessly integrates with Symfony applications.

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

[](#installation)

To install the Encrypter Bundle, run the following command:

```
composer require manojx/encrypter-bundle
```

Configuration
-------------

[](#configuration)

To configure the Encrypter Bundle, you need to create a configuration file. Follow these steps:

1. **Create the Configuration File**: Navigate to the `config/packages` directory of your Symfony project and create a new file named `encrypter.yaml`.

```
touch config/packages/encrypter.yaml
```

2. Add Configuration Content: Open the newly created encrypter.yaml file in your text editor and add the following content:

```
encrypter:
  secret: 'your16-32-64key' # Replace with your actual secret key
```

Ensure that the secret key is either 16, 32, or 64 bytes long. This key will be used for encryption and decryption operations.

Available Methods
-----------------

[](#available-methods)

The Encrypter Bundle provides several methods for encryption, decryption, key generation, and salt generation. Below is a list of each method along with a brief description:

### `encrypt(string $data, ?string $salt = null): string`

[](#encryptstring-data-string-salt--null-string)

Encrypts the given data using the AES-256-CBC encryption algorithm.

- **Parameters**:

    - `string $data`: The plaintext data to encrypt.
    - `string|null $salt`: An optional salt to use for key derivation.
- **Returns**: The encrypted data, encoded in Base64 format, including the initialization vector (IV).

### `decrypt(string $data, ?string $salt = null): string`

[](#decryptstring-data-string-salt--null-string)

Decrypts the given encrypted data.

- **Parameters**:

    - `string $data`: The encrypted data to decrypt.
    - `string|null $salt`: An optional salt that was used during encryption.
- **Returns**: The original plaintext data.
- **Throws**: An exception if decryption fails.

### `generateEncryptionKey(int $length = 32): string`

[](#generateencryptionkeyint-length--32-string)

Generates a random encryption key.

- **Parameters**:

    - `int $length`: The desired length of the encryption key in bytes. Valid lengths are 16, 32, or 64 bytes. Defaults to 32 bytes.
- **Returns**: The generated random encryption key, represented as a hexadecimal string.
- **Throws**: An exception if the length is not valid.

### `generateSalt(int $length = 16): string`

[](#generatesaltint-length--16-string)

Generates a random salt.

- **Parameters**:

    - `int $length`: The desired length of the salt in bytes. Valid lengths are 16, 32, or 64 bytes. Defaults to 16 bytes.
- **Returns**: The generated random salt, represented as a hexadecimal string.
- **Throws**: An exception if the length is not valid.

Usage
-----

[](#usage)

To use the Encrypter Bundle in your Symfony application, you can inject the `EncrypterInterface` into your services or controllers. Here's an example of how you can encrypt and decrypt data:

```
use ManojX\EncrypterBundle\EncrypterInterface;

class YourService
{
    private EncrypterInterface $encrypter;

    public function __construct(EncrypterInterface $encrypter)
    {
        $this->encrypter = $encrypter;
    }

    public function encryptData(string $data): string
    {
        $salt = 'your-salt'; // Define your salt
        return $this->encrypter->encrypt($data, $salt);
    }

    public function decryptData(string $encryptedData): string
    {
        $salt = 'your-salt'; // Use the same salt for decryption
        return $this->encrypter->decrypt($encryptedData, $salt);
    }
}
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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

Total

3

Last Release

590d ago

PHP version history (2 changes)1.0.0PHP ^7.4

1.0.1PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/377edf5fb11ab11c47cd9c3dbd7026e2325caca58a0048073f5ca03d76d8e0f7?d=identicon)[manojx](/maintainers/manojx)

---

Top Contributors

[![manojxio](https://avatars.githubusercontent.com/u/7418454?v=4)](https://github.com/manojxio "manojxio (7 commits)")

---

Tags

symfonybundleencryptiondecryptionencrypteraes-256-cbc

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/manojx-encrypter-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/manojx-encrypter-bundle/health.svg)](https://phpackages.com/packages/manojx-encrypter-bundle)
```

###  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)[rezzza/security-bundle

Signed requests check

1753.6k](/packages/rezzza-security-bundle)

PHPackages © 2026

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