h-farm/laravel-encryptable
Transparently encrypt Eloquent model attributes at rest with a simple trait. Values are encrypted on save and decrypted on read, so your code keeps working with plain strings while the database stores only ciphertext. A drop-in Laravel package that's easy to configure.
composer require maize-tech/laravel-encryptable. Version 4.1.0 adds support for Laravel 13 and PHP 8.5; no breaking changes from 4.0.0.Encryptable trait to any Eloquent model that needs transparent attribute encryption.$encryptable array (check the README for the exact property name in your version).Crypt::encryptString() / decryptString() calls in every model.TEXT or larger columns. Ciphertext is substantially longer than plaintext; VARCHAR(255) is often too small for anything beyond short strings.where clauses because ciphertext differs per row (random IV). For lookup fields, store a deterministic hash (e.g. hash('sha256', $value)) in a separate indexed column and query that.->create() followed by direct DB assertions will show ciphertext.$hidden and $visible to avoid leaking sensitive data through APIs.APP_KEY without re-encrypting existing rows will make old data unreadable. Plan a migration or re-save strategy if rotation is required.encrypted cast, do not also include the same attribute in the package’s encryptable list—double encryption will break reads. Choose one approach per attribute.where on encrypted columns: Queries like where('ssn', $value) will silently return no results. Use a hash column for equality searches, or decrypt in PHP for small datasets.Crypt::decryptString($raw) in tinker.How can I help you explore Laravel packages today?