All Projects → sagalbot → encryptable

sagalbot / encryptable

Licence: GPL-3.0 license
Laravel package for persisting encrypted Model properties, providing decryption when accessed.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to encryptable

Laravel Lucene Search
Laravel 4.2, 5.* package for full-text search over Eloquent models based on ZF2 Lucene.
Stars: ✭ 75 (+188.46%)
Mutual labels:  eloquent, eloquent-models
laravel-nestedupdater
Package for allowing updating of nested Eloquent model relations using a single nested data array.
Stars: ✭ 19 (-26.92%)
Mutual labels:  eloquent, eloquent-models
Laravel Schedulable
Schedule and unschedule eloquent models elegantly without cron jobs
Stars: ✭ 78 (+200%)
Mutual labels:  eloquent, eloquent-models
Laravel Database Encryption
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
Stars: ✭ 238 (+815.38%)
Mutual labels:  eloquent, eloquent-models
inertiajs-tables-laravel-query-builder
Inertia.js Tables for Laravel Query Builder
Stars: ✭ 391 (+1403.85%)
Mutual labels:  eloquent, eloquent-models
Eloquentfilter
An Eloquent Way To Filter Laravel Models And Their Relationships
Stars: ✭ 1,113 (+4180.77%)
Mutual labels:  eloquent, eloquent-models
Laravel Nullable Fields
Handles saving empty fields as null for Eloquent models
Stars: ✭ 88 (+238.46%)
Mutual labels:  eloquent, eloquent-models
Eloquent Approval
Approval process for Laravel Eloquent models
Stars: ✭ 79 (+203.85%)
Mutual labels:  eloquent, eloquent-models
Laravel Deletable
👾 Gracefully restrict deletion of Laravel Eloquent models
Stars: ✭ 137 (+426.92%)
Mutual labels:  eloquent, eloquent-models
Searchable
Search/filter functionality for Laravel's Eloquent models
Stars: ✭ 113 (+334.62%)
Mutual labels:  eloquent, eloquent-models
Laravel Transactional Model Events
Add eloquent model events fired after a transaction is committed or rolled back
Stars: ✭ 52 (+100%)
Mutual labels:  eloquent, eloquent-models
eloquence
Eloquence provides a cache on top of Eloquent that prevents multiple models being created for a single database row using the Identity Map design pattern.
Stars: ✭ 18 (-30.77%)
Mutual labels:  eloquent, eloquent-models
Laravel Cascade Soft Deletes
Cascading deletes for Eloquent models that implement soft deletes
Stars: ✭ 498 (+1815.38%)
Mutual labels:  eloquent, eloquent-models
Elasticquent
Maps Laravel Eloquent models to Elasticsearch types
Stars: ✭ 1,172 (+4407.69%)
Mutual labels:  eloquent, eloquent-models
laravel-autonumber
Laravel package to create autonumber for Eloquent model
Stars: ✭ 26 (+0%)
Mutual labels:  eloquent, eloquent-models
Eloquent Relativity
Allows you to decouple your eloquent models from one another.
Stars: ✭ 112 (+330.77%)
Mutual labels:  eloquent, eloquent-models
Eloquent Hashids
On-the-fly hashids for Laravel Eloquent models. (🍰 Easy & ⚡ Fast)
Stars: ✭ 196 (+653.85%)
Mutual labels:  eloquent, eloquent-models
laravel-quasar
⏰📊✨Laravel Time Series - Provides an API to create and maintain data projections (statistics, aggregates, etc.) from your Eloquent models, and convert them to time series.
Stars: ✭ 78 (+200%)
Mutual labels:  eloquent, eloquent-models
ArtisanUI
CLI UI for Laravel Artisan. https://medium.com/@vlreshet/cli-interface-for-laravel-artisan-4efbcc7d3e5d [en] https://habr.com/ru/post/485952/ [ru]
Stars: ✭ 31 (+19.23%)
Mutual labels:  composer-package
Bouncer
Eloquent roles and abilities.
Stars: ✭ 2,763 (+10526.92%)
Mutual labels:  eloquent

Encryptable Eloquent Model Properties Build Status

A Laravel 5 package that allows you to store Eloquent model properties encrypted in your database, and automatically decrypts them when you need to access them.

example

Install

composer require sagalbot/encryptable

Usage

This package is really just a simple trait and property that you can add to your Eloquent models. Usage is simple:

  1. Before using Laravel's encrypter, you must set a key option in your config/app.php configuration file.

    artisan key:generate

    note: If you already have APP_KEY set in your .env, you should skip this step.

  2. Use the Sagalbot\Encryptable\Encryptable trait:

    use \Sagalbot\Encryptable\Encryptable;
  3. Set the $encryptable array on your Model.

    protected $encryptable = ['my_encrypted_property'];
  4. That's it! Here's a complete example:

    <?php
    
    namespace App;
    
    use Illuminate\Database\Eloquent\Model;
    use Sagalbot\Encryptable\Encryptable;
    
    class MyEncryptedModel extends Model
    {
    
        use Encryptable;
    
        /**
         * The attributes that should be encrypted when stored.
         *
         * @var array
         */
        protected $encryptable = [ 'my_encrypted_property', 'another_secret' ];
    }

Encryption Options

By default, the package uses the global encrypt() and decrypt() Laravel functions, which are just aliases to resolve the Illuminate\Encryption\Encrypter::class out of the container. Laravel's encrypter uses OpenSSL to provide AES-256 and AES-128 encryption, which you can read more about at the Laravel Docs.

If you need to adjust how a specific model encrypts and decrypts its properties, you can override the decryptAttribute and encryptAttribute methods on your model:

/**
 * @param $value
 */
protected function encryptAttribute($value)
{
    //  encrypt the value
}


/**
 * @param $value
 */
protected function decryptAttribute($value)
{
    //  decrypt the value
}

Keep It Secret, Keep It Safe

Keep it Secret, Keep it Safe

Don't lose your encryption key - you can't decrypt your stored data without it.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].