spatie/laravel-ciphersweet
Laravel wrapper for Paragonie CipherSweet that adds searchable field-level encryption to Eloquent models. Encrypt/decrypt sensitive attributes and generate blind indexes so you can query encrypted data securely without exposing readable values in your database.
UsesCipherSweet trait and CipherSweetEncrypted interface provide a declarative way to define encrypted fields, reducing boilerplate.addBlindIndex) enables exact-match searches on encrypted data, a critical requirement for user authentication (e.g., email/username lookup) or internal tools (e.g., customer support dashboards).ciphersweet-migrations) to add encrypted_rows and blind_indexes tables.text (for encrypted storage).ciphersweet:encrypt to backfill existing data (restartable for large datasets)..env for key storage (default) or supports file-based or custom providers, allowing alignment with existing secrets management (e.g., AWS KMS, HashiCorp Vault).EncryptedUniqueRule for form validation, reducing custom validation logic for encrypted fields.ciphersweet:encrypt), which can be resource-intensive. Plan for downtime or staggered rotation in high-availability systems.text type, which may conflict with existing schema constraints (e.g., varchar limits). Requires migration planning.nacl backend suffice, or is a custom backend needed?text field limits).sodium (for NaCl backend) or openssl (for FIPS) must be enabled..env, AWS KMS, or custom provider).composer require spatie/laravel-ciphersweet
php artisan vendor:publish --tag="ciphersweet-migrations"
php artisan migrate
CipherSweetEncrypted and UsesCipherSweet traits.configureCipherSweet() (e.g., email, ssn).php artisan ciphersweet:generate-key
Store the key in .env (CIPHERSWEET_KEY) or a secure vault.php artisan ciphersweet:encrypt App\User <key>
For large datasets, use queues or batch processing:
php artisan queue:work --queue=ciphersweet
$user->email still works).Rule::unique() with EncryptedUniqueRule for encrypted fields.How can I help you explore Laravel packages today?