Download the PHP package spatie/laravel-ciphersweet without Composer

On this page you can find all versions of the php package spatie/laravel-ciphersweet. 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 laravel-ciphersweet

Use CipherSweet in your Laravel project

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

In your project, you might store sensitive personal data in your database. Should an unauthorised person get access to your DB, all sensitive can be read which is obviously not good.

To solve this problem, you can encrypt the personal data. This way, unauthorized persons cannot read it, but your application can still decrypt it when you need to display or work with the data.

CipherSweet is a backend library developed by Paragon Initiative Enterprises for implementing searchable field-level encryption. It can encrypt and decrypt values in a very secure way. It is also able to create blind indexes. These indexes can be used to perform searches on encrypted data. The indexes themselves are unreadable by humans.

Our package is a wrapper over CipherSweet, which allows you to easily use it with Laravel's Eloquent models.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

You must publish and run the migrations with:

Optionally, you can publish the config file with:

This is the contents of the config file:

Usage

Few steps are involved to store encrypted values. Let's go through them.

1. Preparing your model and choosing the attributes that should be encrypted

Add the CipherSweetEncrypted interface and UsesCipherSweet trait to the model that you want to add encrypted fields to.

You'll need to implement the configureCipherSweet method to configure CipherSweet.

 * ->addField('column_name')
 * ->addBooleanField('column_name')
 * ->addIntegerField('column_name')
 * ->addTextField('column_name')
 * 
 * ->addOptionalTextField('column_name')
 * ->addOptionalBooleanField('column_name')
 * ->addOptionalFloatField('column_name')
 * ->addOptionalIntegerField('column_name')
 * 
 * ->addJsonField('column_name', $fieldMap)
 * 
 * ->addBlindIndex('column_name', new BlindIndex('column_name_index'))
 * 

The example above will encrypt the email field on the User model. It also adds a blind index in the blind_indexes table which allows you to search on it.

Check out the CipherSweet PHP docs for more information on what is possible.

2. Generating the encrypting key

An encryption key is used to encrypt your values. You can generate a new CipherSweet encrypting key using this command:

3. Updating your .env file

After the key has been generated, you should add the generated CipherSweet key to your .env file.

The key will be used by your application to manage encrypted values.

4. Encrypting model attributes

With this in place, you can run this command to encrypt all values:

The command will update all the encrypted fields and blind indexes of the model.

If you have a lot of rows, this process can take a long time. The command is restartable: it can be re-run without needing to re-encrypt already rotated keys.

Searching on blind indexes

Even though values are encrypted, you can still search them using a blind index. The blind indexes will have been built up when you ran the command to encrypt the model values.

This package provides a whereBlind and orWhereBlind scope to search on blind indexes.

The first parameter is the column, the second the index name you set up when calling ->addBlindIndex, the third is the raw value, the package will automatically apply any transformations and hash the value to search on the blind index.

Rotating keys

Should you suspect that somebody got a hold of your encrypting key, you can re-encrypt the values. Simply generate another encrypting key, and run the php artisan ciphersweet:encrypt command again.

This will update all the encrypted fields and blind indexes of the model. Once this is done, you can update your environment or config file to use the new key.

Implementing a custom backend

You can implement a custom backend by setting the ciphersweet.backend config value to custom.

The ciphersweet.backend.custom config value must then be set to an invokeable factory class that returns an implementation of ParagonIE\CipherSweet\Contract\BackendInterface

Implementing a custom key provider

You can implement a custom key provider by setting the ciphersweet.provider config value to custom.

The ciphersweet.providers.custom config value must then be set to an invokeable factory class that returns an implementation of ParagonIE\CipherSweet\Contract\KeyProviderInterface

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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


All versions of laravel-ciphersweet with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/contracts Version ^9.19|^10.0|^11.0
paragonie/ciphersweet Version ^4.0.1
spatie/laravel-package-tools Version ^1.12.0
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 spatie/laravel-ciphersweet contains the following files

Loading the files please wait ....