paragonie/ciphersweet
CipherSweet is a PHP library for field-level encryption with searchable encrypted data. It helps you securely encrypt database columns while still supporting safe, blind-index-based search and sorting, with modern cryptography and key management support.
config('app.cipher')).paragonie/ciphersweet-db), but requires schema changes (e.g., adding ciphertext, salt, nonce columns).spatie/laravel-ciphersweet). May need middleware for request/response encryption..env integration is straightforward but lacks built-in rotation.pgcrypto). Complex joins/aggregations may need workarounds.tsvector on decrypted data).ciphertext, salt, nonce) without migrations?LIKE, JOIN) on encrypted fields? If so, what’s the fallback strategy?paragonie/ciphersweet-db (uses pgcrypto for some operations).LIKE or full-text search on encrypted fields.passwords, credit_cards, SSNs) for encryption candidates.ciphertext, salt, nonce columns to target tables (use Laravel migrations).Schema::table('users', function (Blueprint $table) {
$table->binary('email_ciphertext')->nullable();
$table->binary('email_salt')->nullable();
$table->binary('email_nonce')->nullable();
});
CipherSweet via a service provider:
$this->app->singleton(CipherSweet::class, function ($app) {
return new CipherSweet(config('ciphersweet.keys'));
});
trait EncryptedEmail {
public function getEmailAttribute($value) {
return $this->decrypt($this->attributes['email_ciphertext']);
}
public function setEmailAttribute($value) {
$this->attributes['email_ciphertext'] = $this->encrypt($value);
}
}
// Before
$users = User::where('email', 'like', '%@gmail.com%')->get();
// After (application-layer filter)
$users = User::all()->filter(fn ($user) => str_contains($user->email, '@gmail.com'));
pgcrypto where possible.public function handle($request, Closure $next) {
$response = $next($request);
$response->getData()->transform(function ($data) {
return collect($data)->mapWithKeys(function ($value, $key) {
return $this->decryptIfNeeded($key, $value);
});
});
return $response;
}
email, phone) in a staging environment.users, orders).tsvector on decrypted data).CipherSweet::reencrypt().paragonie/ciphersweet for security patches (e.g., new ChaCha20 variants).How can I help you explore Laravel packages today?