PHPackages                             wizofgoz/cryptographer - 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. [Security](/categories/security)
4. /
5. wizofgoz/cryptographer

ActiveLibrary[Security](/categories/security)

wizofgoz/cryptographer
======================

An extensible encryption system for Laravel

v0.3(6y ago)112[1 issues](https://github.com/Wizofgoz/Cryptographer/issues)[4 PRs](https://github.com/Wizofgoz/Cryptographer/pulls)MITPHPPHP &gt;=7.1.0

Since Jan 26Pushed 3y ago2 watchersCompare

[ Source](https://github.com/Wizofgoz/Cryptographer)[ Packagist](https://packagist.org/packages/wizofgoz/cryptographer)[ Docs](https://github.com/wizofgoz/Cryptographer)[ RSS](/packages/wizofgoz-cryptographer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (8)Versions (10)Used By (0)

Cryptographer
=============

[](#cryptographer)

[![Build Status](https://camo.githubusercontent.com/c458ec63ed0cfe2519659d7854fa33a2ba00c2edf7adaec173a45163be295f17/68747470733a2f2f7472617669732d63692e6f72672f57697a6f66676f7a2f43727970746f677261706865722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Wizofgoz/Cryptographer)[![Style Status](https://camo.githubusercontent.com/5de95709135ef9a8d8b676ead275113a80d387bfef6b832f7b475bee8f72e4d6/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3136373435323632382f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/167452628)[![Total Downloads](https://camo.githubusercontent.com/ee7352b586b51af1a8ecd266bcc4c1e4530002173938371cfcfe664f3b7c90a3/68747470733a2f2f706f7365722e707567782e6f72672f77697a6f66676f7a2f63727970746f677261706865722f646f776e6c6f616473)](https://packagist.org/packages/wizofgoz/cryptographer)[![Latest Stable Version](https://camo.githubusercontent.com/de587bb8ea1501114347c7469b9a4d42b6b95af56a030d40f10bc9cec4d1f1cf/68747470733a2f2f706f7365722e707567782e6f72672f77697a6f66676f7a2f63727970746f677261706865722f762f737461626c652e737667)](https://packagist.org/packages/wizofgoz/cryptographer)[![License](https://camo.githubusercontent.com/c835e80c975d7e735b92c4b6967ba099d8fa1ab2097ca04dcf017447def76a79/68747470733a2f2f706f7365722e707567782e6f72672f77697a6f66676f7a2f63727970746f677261706865722f6c6963656e73652e737667)](https://packagist.org/packages/wizofgoz/cryptographer)

Introduction
------------

[](#introduction)

Cryptographer provides an extensible replacement for Laravel's encryption service. It also allows you to define multiple drivers that can be used for different areas of your application.

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

[](#installation)

You may use Composer to install Cryptographer into your Laravel project:

`composer require wizofgoz/cryptographer`

After installing, publish the configuration:

`php artisan vendor:publish --provider="Wizofgoz\Cryptographer\EncryptionServiceProvider"`

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

[](#configuration)

After publishing the configuration file, it will be located at `config/cryptographer.php` This file allows you to define the encryption drivers available to your application.

### Defaults

[](#defaults)

These options allow you to define the default encryption driver and key to use when using the encryption service. If no default driver is set, the first entry in the drivers array will be used.

```
'default-driver' => 'default',
'default-key'    => 'default',
```

### Available Drivers

[](#available-drivers)

This array allows for defining the encryption drivers available to your application. Each entry in the list MUST contain an engine, cipher, and key name for proper use.

```
'drivers' => [
    'default' => [
        'engine' => 'openssl',
        'cipher' => OpenSslEngine::CIPHER_AES_128,
        'key'    => 'default',
    ],
],
```

### Keys

[](#keys)

This array allows for defining multiple keys for use with your encryption drivers. Each key must have a unique name.

#### Local Driver

[](#local-driver)

The simplest key implementation is one that is managed locally. With this driver, the key is visible locally in plaintext and is loaded directly into the encryption driver being used.

```
'default' => [
    'driver' => 'local',
    'value' => env('APP_KEY'),
],
```

#### AWS Driver

[](#aws-driver)

When it is unacceptable for the key to be stored in plaintext, the AWS driver is able to use a local key that has been encrypted with an AWS KMS consumer key.

This allows you to rotate the encryption of the key and not have to re-encrypt all the data the key was used to encrypt.

```
'kms' => [
    'driver'     => 'aws',
    'value'      => env('AWS_DATA_KEY'), // encrypted value of the local data key
    'region'     => 'us-west-2',
    'profile'    => 'default', // credentials to use from ~/.aws/credentials file
    'master-key' => 'key_id_for_making_data_key', // ARN or key ID of master key to use
    'context'    => [], // optional key/values for authenticating key material
],
```

Usage
-----

[](#usage)

This package integrates with Laravel's encryption system and either the built-in `encrypt()` and `decrypt()` helpers or the `Crypt` facade may be used when you want to utilize your default driver.

In order to use additional drivers, either the `Crypt` facade must be used as shown below:

```
use Illuminate\Support\Facades\Crypt;

$encrypted = Crypt::driver('something')->encrypt('Hello world.');
```

Or the `ncrypt` and `dcrypt` helper functions must be used:

```
$encrypted = ncrypt('some value', 'driver_name');

$plaintext = dcrypt($encrypted, 'driver_name');
```

### Key Generation

[](#key-generation)

Encryption keys can be generated using the command `php artisan crypt:key:generate` and there are the following options available:

- `--driver` the name of the driver from your configuration to use.
- `--engine` an override of the engine to use when generating a key.
- `--cipher` an override of the cipher to use when generating a key.
- `--key-driver` an override of the key driver to use when generating a key.
- `--aws-master-key` an override of the AWS CMK to use for encrypting a local data key (Only used for AWS key driver).
- `--aws-region` an override of the AWS region to use for making calls to the AWS API (Only used for AWS key driver).
- `--aws-context` an override of any custom context to use for encrypting the local data key (Only used for AWS key driver).
- `--environment` what environment variable to set in your .env file. Defaults to `APP_KEY`.
- `--show` to display the key instead of applying it to configuration and environment.
- `--force` force the operation to run when in production.

Available Engines
-----------------

[](#available-engines)

### OpenSSL

[](#openssl)

The `openssl` engine is drop-in replacement for Laravel's encryption system that will work with existing keys assuming the cipher is set correctly.

#### Supported Ciphers

[](#supported-ciphers)

- `OpenSslEngine::CIPHER_AES_128`: AES-128-CBC - default
- `OpenSslEngine::CIPHER_AES_256`: AES-256-CBC

### Sodium

[](#sodium)

The `sodium` engine depends on the [Sodium](http://php.net/manual/en/book.sodium.php) PHP extension and will not be available if it is missing. In PHP 7.2+, the Sodium extension is part of the core and should always be available.

#### Supported Ciphers

[](#supported-ciphers-1)

- `SodiumEngine::CIPHER_AES_256`: AES-256-GCM - requires hardware support
- `SodiumEngine::CIPHER_CHACHA`: CHACHA-20-POLY-1305
- `SodiumEngine::CIPHER_CHACHA_IETF`: CHACHA-20-POLY-1305-IETF
- `SodiumEngine::CIPHER_X_CHACHA_IETF`: XCHACHA-20-POLY-1305-IETF - default

Extensions
----------

[](#extensions)

Custom encryption engines are expected to implement the `Wizofgoz\Cryptographer\Contracts\Engine` contract and can be added by simply extending `EncryptionManager`:

```
public function register()
{
    $this->app->resolving('encrypter', function ($encrypter) {
        $encrypter->extend('engine_name', function ($config) {
            return new CustomEngine($config);
        });
    });
}
```

Custom key drivers are expected to implement the `Wizofgoz\Cryptographer\Contracts\KeyDriver` contract and can be added in a very similar manner by extending the `KeyManager`:

```
public function register()
{
    $this->app->resolving('key-manager', function ($km) {
        $km->extend('driver_name', function ($config) {
            return new CustomDriver($config);
        });
    });
}
```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~124 days

Total

3

Last Release

2411d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d8a59805c1199f66a3a25c99de161397fd4e4d293753216ef1c872b2db169d1b?d=identicon)[Wizofgoz](/maintainers/Wizofgoz)

---

Top Contributors

[![Wizofgoz](https://avatars.githubusercontent.com/u/10892542?v=4)](https://github.com/Wizofgoz "Wizofgoz (40 commits)")

---

Tags

encryptionlaravellaravelencryptionlibsodium

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wizofgoz-cryptographer/health.svg)

```
[![Health](https://phpackages.com/badges/wizofgoz-cryptographer/health.svg)](https://phpackages.com/packages/wizofgoz-cryptographer)
```

###  Alternatives

[ercsctt/laravel-file-encryption

Secure file encryption and decryption for Laravel applications

642.6k](/packages/ercsctt-laravel-file-encryption)

PHPackages © 2026

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