PHPackages                             bjornvoesten/laravel-ciphersweet - 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. bjornvoesten/laravel-ciphersweet

Abandoned → [bjorn-voesten/ciphersweet-for-laravel](/?search=bjorn-voesten%2Fciphersweet-for-laravel)ArchivedLibrary

bjornvoesten/laravel-ciphersweet
================================

Laravel CipherSweet

0.2(2y ago)1040610MITPHPPHP ^7.2

Since Nov 11Pushed 2y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (5)Versions (7)Used By (0)

This repository has been deprecated in favor of:

---

Laravel CipherSweet: Searchable Encrypted Attributes
====================================================

[](#laravel-ciphersweet-searchable-encrypted-attributes)

> Hey! I have to say that I'm not very active maintaining this package, but you may always send pull requests!

**Laravel CipherSweet** is a [Laravel](https://laravel.com) implementation of [Paragon Initiative Enterprises CipherSweet](https://ciphersweet.paragonie.com) searchable field level encryption.

[![Preview](https://user-images.githubusercontent.com/10741416/68589760-10fae780-048d-11ea-850b-5c7733f0f4f7.png)](https://user-images.githubusercontent.com/10741416/68589760-10fae780-048d-11ea-850b-5c7733f0f4f7.png)

Make sure you have some basic understanding of [CipherSweet](https://ciphersweet.paragonie.com) before continuing.

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

[](#installation)

Install the package using composer:

```
composer require bjornvoesten/laravel-ciphersweet
```

Publish configuration file:

```
php artisan vendor:publish --tag=ciphersweet-config
```

Generate an encryption key:

```
php artisan ciphersweet:key
```

**Watch out!**All encrypted columns depend on this key. If the key changes, the already encrypted columns can not be decrypted anymore!

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

[](#configuration)

#### Algorithm

[](#algorithm)

You can change the encryption algorithm by defining the crypto:

```
ENCRYPTION_CRYPTO=modern/fips
```

For more information about the encryption index algorithms see the [documentation](https://ciphersweet.paragonie.com/internals/blind-index).

Usage
-----

[](#usage)

### Defining encryption

[](#defining-encryption)

Add the `Bjornvoesten\CipherSweet\Traits\HasEncryption` trait to the model.

```
    use HasEncryption;
```

Define the attributes that should ben encrypted.

```
    /**
     * The attributes that can be encrypted.
     *
     * @var array
     */
    protected $encrypted = [
        'social_security_number',
    ];
```

By default the index column name is generated using the name and suffixing it with `_index`.

So the `social_security_number` attribute will use the default index column `social_security_number_index`.

Alternatively you can define multiple indexes per attribute and and define more options.

```
    /**
     * Set the social security number attribute encryption.
     *
     * @param \Bjornvoesten\CipherSweet\Contracts\Attribute $attribute
     * @return void
     */
    public function socialSecurityNumberAttributeEncryption($attribute): void
    {
        $attribute
            ->index('social_security_number_full_index', function (Index $index) {
                $index
                    ->bits(32)
                    ->slow();
            })
            ->index('social_security_number_last_four_index', function (Index $index) {
                $index
                    ->bits(16)
                    ->transform(
                        new LastFourDigits()
                    );
            });
    }
```

For more information about the index options see the [documentation](https://ciphersweet.paragonie.com/php/usage).

And make sure you have created the index columns in the database table!

### Searching models

[](#searching-models)

You can search encrypted attributes by using the default `where` clause on the query builder or with the `whereEncrypted` method.

```
 \App\User::query()
    ->where('social_security_number', '=', $number)
    ->get();
```

By using the `whereEncrypted` method you can also define the indexes which can be searched.

```
 \App\User::query()
    ->whereEncrypted('social_security_number', '=', $number, [
        'social_security_number_last_four_index',
    ])
    ->get();
```

**Note** When searching with the `equal to` operator models will be returned when the value is found in one of all available or defined indexes. When searching with the `not equal to` operator all models where the value is not found in any of the available or the defined indexes are returned.

#### Caveat

[](#caveat)

Because of the limited search possibilities in CipherSweet only the `=` and `!=` operators are available when searching encrypted attributes.

Testing
-------

[](#testing)

```
$ composer test
```

To be done.

License
-------

[](#license)

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

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 77.8% 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 ~404 days

Total

5

Last Release

756d ago

PHP version history (2 changes)0.1.0PHP ^7.3

0.1.1PHP ^7.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10741416?v=4)[Bjorn Voesten](/maintainers/bjornvoesten)[@bjornvoesten](https://github.com/bjornvoesten)

---

Top Contributors

[![bjornvoesten](https://avatars.githubusercontent.com/u/10741416?v=4)](https://github.com/bjornvoesten "bjornvoesten (7 commits)")[![pgtruesdell](https://avatars.githubusercontent.com/u/798421?v=4)](https://github.com/pgtruesdell "pgtruesdell (1 commits)")[![wprigollopes](https://avatars.githubusercontent.com/u/8663950?v=4)](https://github.com/wprigollopes "wprigollopes (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bjornvoesten-laravel-ciphersweet/health.svg)

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

###  Alternatives

[owen-it/laravel-auditing

Audit changes of your Eloquent models in Laravel

3.4k33.0M95](/packages/owen-it-laravel-auditing)[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[casbin/laravel-authz

An authorization library that supports access control models like ACL, RBAC, ABAC in Laravel.

324339.9k4](/packages/casbin-laravel-authz)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

44643.1k1](/packages/pressbooks-pressbooks)[illuminatech/balance

Provides support for Balance accounting system based on debit and credit principle

16137.4k](/packages/illuminatech-balance)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)

PHPackages © 2026

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