Download the PHP package thomascombe/encryptable-fields without Composer

On this page you can find all versions of the php package thomascombe/encryptable-fields. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package encryptable-fields

Eloquent model encrypted fields for Laravel

Latest Version on Packagist Total Downloads

Allow you to encrypt model's fields. You can add a hashed field to allow SQL query.

Installation

You can install the package via composer:

You can publish the configuration via Artisan:

Usage

To work with this package, you need to use our EncryptableFields trait in your models, then override the $encryptable property. This array allows you to define encryptable attributes in your model.

You can also add attributes to contain a hash of the non encrypted value, which might be useful in order to execute a fast full match for a given searched value.

To do so, you need to use the $encryptable property as an associative array, where encryptable attributes are keys and associated hashed attributes are values.

To create a new model, simply do it as before:

To find a model from a hashed value:

or use the model's local scope:

Authentication

An auth provider, eloquent-hashed, is registered by this package and allows to authenticate users on a hashed attribute, per example an email. To use it, simply change your auth configuration as follows:

Searchable encrypted values

MySQL and MariaDB both provide an aes_decrypt function, allowing to decrypt values directly when querying. It then becomes possible to use this function to filter or sort encrypted values.

However, Laravel default encrypter only handles AES-128-CBC and AES-256-CBC cipher methods, where MySQL and MariaDB requires AES-128-ECB. We're going to use two different keys.

To do so, add the following variable to your .env file:

and run php artisan encryptable-fields:key-generate command to generate a database encryption key.

⚠️ You shouldn't generate this key on your own because ciphers differ between Laravel and MySQL/MariaDB.

Then, it is required to override Laravel's default encrypter, which is done in DatabaseEncrypter.php.

Include DatabaseEncryptionServiceProvider in your config/app.php, so that a singleton instance will be registered in your project, under databaseEncrypter key:

Finally, override the package configuration in encryptable-fields.php file:

⚠️ With DatabaseEncrypter.php, values are not serialized in order to allow querying with exact values (= instead of like operator), which means it won't handle object instances or arrays.

If you're using Laravel Backpack in your project, a trait EncryptedSearchTrait provides methods to customize search and order logics.

Validation

This package comes with some rules to validate existence and uniqueness for a hashed or encrypted attribute.

They work as extensions for Illuminate\Validation\Rules\Exists and Illuminate\Validation\Rules\Unique.

Hashed

and

Encrypted

and

Hide decrypt value in log

If your application use spatie/laravel-activitylog or webqamdev/activity-logger-for-laravel :
Add HasEncryptableFieldsLog trait in each model with logs.
This trait print encrypted values in log instead of decrypt values.

Testing

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.


All versions of encryptable-fields with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1
illuminate/support Version >=5.8
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package thomascombe/encryptable-fields contains the following files

Loading the files please wait ....