PHPackages                             rahulshibu/laravel-model-encrypter - 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. rahulshibu/laravel-model-encrypter

ActiveLibrary

rahulshibu/laravel-model-encrypter
==================================

Provides database model attribute encryption/decryption

038PHP

Since May 15Pushed 5y agoCompare

[ Source](https://github.com/rahulshibu/laravel-model-encrypter)[ Packagist](https://packagist.org/packages/rahulshibu/laravel-model-encrypter)[ RSS](/packages/rahulshibu-laravel-model-encrypter/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Db Encrypter Package
============================

[](#laravel-db-encrypter-package)

This package was created to encrypt and decrypt values of Eloquent model attributes.

Key features
------------

[](#key-features)

- Encrypt, decrypt values stored in database fields
- Using standard Laravel's Crypt service
- Easy configuration

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

[](#requirements)

- Laravel: 6.0 and up
- PHP: 7.1 and newer

#### Database schema

[](#database-schema)

Encrypted values are stored as plain text so in most cases takes up more spaces then unencrypted one. Recommendation is to alter table column to `TEXT` type. If you want use `VARCHAR` or `CHAR` column type still you need to check if encrypted value fit.

#### Note:

[](#note)

Do not worry if you have current data in your database not encrypted and added column to `$encryptable` - they will return as is.
On save values will be encrypted and everything will work fine.

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

[](#installation)

Via Composer command line:

```
$ composer require rahulshibu/laravel-model-encrypter
```

Usage
-----

[](#usage)

1. Use the `LaravelModelEncrypter\Traits\DBEncryptor` trait in any Eloquent model that you wish to use encryption
2. Define a `protected $encryptable` array containing a list of the encrypted attributes.
3. Define the encryption key in .env file. Default encrption key will be empty.

For example:

Model

```

    use LaravelModelEncrypter\Traits\DBEncryptor;

    class Client extends Eloquent {
        use DBEncryptor;

        /** @var array The attributes that should be encrypted/decrypted */
        protected $encryptable = [
            'id_number',
            'email',
        ];
    }
```

ENV

```
ENCRYPT_KEY=abcd1234
```

3. You can use Laravel's original $casts to cast decrypted values

### License

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity33

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/02244df00b2e2b5edcdd962f6b71b9cf0b02e3491aecf605f3531c013266dc06?d=identicon)[rahulshibu](/maintainers/rahulshibu)

---

Top Contributors

[![itsrahul-ab](https://avatars.githubusercontent.com/u/68027110?v=4)](https://github.com/itsrahul-ab "itsrahul-ab (4 commits)")

### Embed Badge

![Health badge](/badges/rahulshibu-laravel-model-encrypter/health.svg)

```
[![Health](https://phpackages.com/badges/rahulshibu-laravel-model-encrypter/health.svg)](https://phpackages.com/packages/rahulshibu-laravel-model-encrypter)
```

PHPackages © 2026

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