PHP / Field encryption + Rust

Encrypt at restQuery as usual

Eloquent casts, SQL decrypt fragments and key rotation, with plain PHP support.

Locky the little lock spirit, the encryptable project pet

Ciphertext at rest, queries intact

Encryptable encrypts attributes on write and decrypts on read; Eloquent casts and the manual API share one OpenSSL path.

For uniqueness and existence checks, DB mode emits MySQL and PostgreSQL SQL decrypt fragments; previous_keys keeps old keys for online rotation.

  • Eloquent attribute casts
  • MySQL / PostgreSQL
  • Key ring and rotation
4Framework bridges
19Test classes
v2.0.13Current version
Locky the little lock spirit Smile expression

Locky

A friendly padlock: the amber key is the current primary key, and the two grey keys on the ring are previous_keys, still able to decrypt old data.

New primary, old keys stay on the ring.

From model attribute to SQL

Framework bridges only wire config; the crypto core stays framework-free.

Eloquent cast

Encryptable::class in $casts transparently handles reads and writes.

PHP-side crypto

Encryption::php() serves CLI, queue and other non-model code paths.

SQL decrypt fragments

Generate MySQL and PostgreSQL snippets for comparisons against ciphertext.

Encrypted validation

UniqueEncrypted and ExistsEncrypted compare deterministic ciphertext.

Key rotation

Primary and previous_keys form a decryption ring for gradual re-encryption.

Four framework bridges

Laravel, Webman, Hyperf and ThinkPHP adapters, plus plain PHP.

Same capability, Rust version

The same field encryption semantics, now available in Rust.

Rust v1.3.0 Rust 1.88 / crate

encryptable-rust

Searchable field encryption in Rust

AES-256-GCM for encryption at rest, AES-256-ECB for lookups by original value, HKDF-derived subkeys, SQL fragments and eight framework integrations.

  • Searchable field encryption
  • Separate keys per path
  • Eight Rust frameworks
View Rust repository

How the features grew

Each release solves one concrete problem instead of piling on features.

v2.0.13

Decrypt compatibility and release automation

Accept base64-prefixed previous_keys, fix how validation rules resolve the encrypter, and automate release notes.

v2.0.12

Social preview

Add a 1280x640 social preview for the GitHub repository and reference it from the README.

v2.0.11

Expression forms in Mascot

Mascot gains expressions() and expression(), shipping 12 expression forms with the package.

v2.0.10

Transparent backgrounds and Markdown

Drop the pet SVG background and switch the README to Markdown tables.

Changelog

Recent releases, with the full list on GitHub Releases.

Latest v2.0.13 All versions
v2.0.132026-10-19

Fix base64 previous_keys and rule lookup; automate release notes.

v2.0.122026-10-18

Add a GitHub social preview image.

v2.0.112026-10-18

Mascot exposes all 12 expression forms.

v2.0.102026-10-18

Transparent pet artwork; the README moves to Markdown.

v2.0.92026-10-18

Transparent backgrounds for expression SVGs.

v2.0.82026-10-18

Reserve commercial rights for visual assets.

Install and use

Install, then run a minimal example.

PHP >= 8.0Full README
Install
composer require erikwang2013/encryptable
Minimal example
use Erikwang2013\Encryptable\Encryption;

$plain = 'value to protect';
$cipher = Encryption::php()->encrypt($plain);

$restored = Encryption::php()->decrypt($cipher);

Locky's 12 expressions

Hover and the mood changes.

Search this site

Try “upload”, “migration” or “JWT”.