magros/laravel-model-encryption
getAttribute/setAttribute overrides), reducing boilerplate but requiring careful attribute selection to avoid unintended encryption (e.g., non-sensitive fields like created_at).encrypt()) or database-level encryption (e.g., PostgreSQL’s pgcrypto) may offer more granular control but lack the convenience of model-level automation.config/encrypt.php allows customization of encryption keys, algorithms (AES-256-CBC default), and excluded fields, reducing hardcoding risks.openssl extension. Key management (e.g., storing encryption keys securely) is the TPM’s responsibility.casts (e.g., date), the package may interfere. Test with complex attribute types.Serializable interface.env).microtime().)bytea for binary storage to avoid Base64 overhead.$model->useQueryCache = false;).is_encrypted metadata column for future flexibility.Encryptable trait to models:
use Magros\Encryptable\Encryptable;
class User extends Model { use Encryptable; }
'fields' => [
'ssn' => ['algorithm' => 'AES-256-CBC'],
'credit_card' => ['exclude_from_search' => true],
],
getAttribute/setAttribute to verify encryption/decryption.exclude_from_search in config.visible/hidden).Log::withoutFiles() or custom log filters to exclude encrypted fields.static properties) for frequently accessed fields.chunk() for large datasets).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Key Loss | Permanent data loss | Backup keys offline; implement key escrow. |
| Corrupted Encrypted Data | Inconsistent |
How can I help you explore Laravel packages today?