PHPackages                             dolphiq/laravel-aescrypt - 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. [Database &amp; ORM](/categories/database)
4. /
5. dolphiq/laravel-aescrypt

ActiveLibrary[Database &amp; ORM](/categories/database)

dolphiq/laravel-aescrypt
========================

AES encrypt and decrypt Eloquent attributes inspired by elocryptfive

1.1.0(1mo ago)171.7k7[3 issues](https://github.com/Dolphiq/laravel-aescrypt/issues)[1 PRs](https://github.com/Dolphiq/laravel-aescrypt/pulls)MITPHPPHP &gt;=7.0

Since Oct 24Pushed 1mo ago6 watchersCompare

[ Source](https://github.com/Dolphiq/laravel-aescrypt)[ Packagist](https://packagist.org/packages/dolphiq/laravel-aescrypt)[ RSS](/packages/dolphiq-laravel-aescrypt/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (3)Dependencies (16)Versions (5)Used By (0)

Eloquent Encryption/Decryption for Laravel 5
============================================

[](#eloquent-encryptiondecryption-for-laravel-5)

READ THIS FIRST
---------------

[](#read-this-first)

This package uses the Openssl AES ECB encrypth method with a key length of 128bit. The result is default compatible with the AES\_ENCRYPT functions and can be reproduces by running the query:

```
set @salt = SUBSTRING(SHA2('My secret pass phrase',256), 1, 16);
SELECT @salt as salt, AES_ENCRYPT('text to encrypt', @salt);

```

With the AESCRYPT\_BASE64\_OUTPUT setting on true, the query will be:

```
set @salt = SUBSTRING(SHA2('My secret pass phrase',256), 1, 16);
SELECT @salt as salt, TO_BASE64(AES_ENCRYPT('text to encrypt', @salt));

```

The package uses a blank IV (just like Mysql) as default. The result hash is the same with the same input text under this conditions. This is less save than using a random IV and NOT recommended for use with data with many repetitions or higly secure data but give one big advantage: You can search the database rather fast for matching text (e.g. email address) without decrypting all records.

Note: Encrypted values are usually longer than plain text values. Sometimes much longer. You may find that the column widths in your database tables need to be extended to store the encrypted values. The package stores the data as Raw hash by default this can be switched to `AESCRYPT_BASE64_OUTPUT = true` in the .env file

If you are using the default encrypthion method, you should change your database columns to VARBINARY (length of 300 will be safe for former 256 varchar), If you turn on AES\_BASE64\_OUTPUT, you can use VARCHAR (length: +/- (original text + 13 + 16) \* 1.3 or TEXT or LONGTEXT.

What Does This Do?
------------------

[](#what-does-this-do)

This encrypts and decrypts columns stored in database tables in Laravel applications transparently, by encrypting data as it is stored in the model attributes and decrypting data as it is recalled from the model attributes.

All data that is encrypted is prefixed with a tag (default `__AESCRYPT__:`) so that encrypted data can be easily identified.

This supports columns that store either encrypted or non-encrypted data to make migration easier. Data can be read from columns correctly regardless of whether it is encrypted or not but will be automatically encrypted when it is saved back into those columns.

Requirements and Recommendations
--------------------------------

[](#requirements-and-recommendations)

- Laravel 5.5 LTS (untested other versions)
- PHP &gt; 7
- PHP [openssl extension](http://php.net/manual/en/book.openssl.php).
- A working OpenSSL implementation on your OS. OpenSSL comes pre-built with most Linux distributions and other forms of Unix such as \*BSD. There may or may not be a working OpenSSL implementation on a Windows system depending on how your LA?P stack was built. I cannot offer support for installing or using ElocryptFive on systems that do not have an OpenSSL library.

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

[](#installation)

This package can be installed via Composer by running following command:

```
    composer require dolphiq/laravel-aescrypt

```

Once `composer` has finished, then add the service provider in Laravel to the `providers` array in your application's `config/app.php` file:

```
    'providers' => [
        ...
        Dolphiq\Aescrypt\AescryptServiceProvider::class,
    ],
```

In Lumen, you can add it to `bootstrap/app.php` file:

```
// Aescrypt provider
$app->register(\Dolphiq\Aescrypt\AescryptServiceProvider::class);
```

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

[](#configuration)

Publish the config file with:

```
    php artisan vendor:publish --provider='Dolphiq\Aescrypt\AescryptServiceProvider'

```

Than you have to add an encryption key`.env` config file:

```
    AESCRYPT_AESKEY=xxxx

```

Usage
-----

[](#usage)

Simply reference the Aescrypt trait in any Eloquent Model you wish to apply encryption to and define an `$encrypts` array containing a list of the attributes to encrypt.

For example:

```
    use Dolphiq\Aescrypt\Aescrypt;

    class User extends Eloquent {

        use Aescrypt;

        /**
         * The attributes that should be encrypted on save.
         *
         * @var array
         */
        protected $encrypts = [
            'username', 'email'
        ];
    }
```

Contributors
------------

[](#contributors)

This is based on the original Darren Taylor's Laravel 4 "elocrypt" package With changes from Delatbabel.

Developers in our team: Johan Zandstra - Brought to you by [Dolphiq](https://dolphiq.nl)

###  Health Score

51

↑

FairBetter than 96% of packages

Maintenance88

Actively maintained with recent releases

Popularity26

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 76.9% 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 ~1541 days

Total

3

Last Release

41d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9dfab1936de2791991111dcf8e0dc68b0ca43d1fedda94dc793e6dadcb467a09?d=identicon)[dolphiq](/maintainers/dolphiq)

---

Top Contributors

[![johanzandstra](https://avatars.githubusercontent.com/u/4737521?v=4)](https://github.com/johanzandstra "johanzandstra (10 commits)")[![marickvantuil](https://avatars.githubusercontent.com/u/647007?v=4)](https://github.com/marickvantuil "marickvantuil (2 commits)")[![brendt](https://avatars.githubusercontent.com/u/6905297?v=4)](https://github.com/brendt "brendt (1 commits)")

---

Tags

laravelencryptioneloquentencryptl5laravel5eloquent encryptioneloquent aeselocryptlaravel5 encryptionlaravel5 aes

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dolphiq-laravel-aescrypt/health.svg)

```
[![Health](https://phpackages.com/badges/dolphiq-laravel-aescrypt/health.svg)](https://phpackages.com/packages/dolphiq-laravel-aescrypt)
```

###  Alternatives

[delatbabel/elocryptfive

Automatically encrypt and decrypt Eloquent attributes with ease.

8493.0k](/packages/delatbabel-elocryptfive)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[laravel-doctrine/orm

An integration library for Laravel and Doctrine ORM

8425.3M87](/packages/laravel-doctrine-orm)[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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