Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Ciphersweet Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Compliance & Security Roadmap:

    • Enable GDPR/CCPA compliance by encrypting PII (Personally Identifiable Information) at rest (e.g., emails, SSNs, payment details).
    • Address regulatory requirements (e.g., HIPAA for healthcare data) by implementing field-level encryption without sacrificing searchability.
    • Build vs. Buy: Avoid reinventing encryption logic; leverage ParagonIE’s battle-tested CipherSweet library with Laravel integration.
  • Searchable Encryption Use Cases:

    • User Authentication: Encrypt emails/usernames while enabling login queries (e.g., User::whereBlind('email', ...)).
    • E-Commerce: Secure customer data (addresses, credit card hashes) while allowing partial searches (e.g., "Find orders with status=shipped").
    • Healthcare: Encrypt patient records (e.g., medical_history) with searchable blind indexes for authorized queries.
  • Data Migration Strategy:

    • Incremental Encryption: Use php artisan ciphersweet:encrypt to migrate existing data without downtime (supports restartable batches).
    • Key Rotation: Plan for periodic key rotation to mitigate exposure risks (e.g., CIPHERSWEET_KEY updates).
  • Validation & UX:

    • Replace manual uniqueness checks with EncryptedUniqueRule for encrypted fields (e.g., email validation during signup).
    • Enable "forgot password" flows by searching encrypted emails via blind indexes.

When to Consider This Package

Adopt if:

  • Your Laravel app stores sensitive PII (e.g., emails, passwords, financial data) in plaintext databases.
  • You need searchable encryption (e.g., "Find users with status=active" without decrypting all records).
  • Compliance mandates field-level encryption (e.g., GDPR, HIPAA) but requires query performance.
  • You’re willing to trade minor query overhead (~10–20ms per encrypted search) for security.

Look elsewhere if:

  • Your data is non-sensitive (e.g., public blog posts) or already hashed (e.g., BCrypt passwords).
  • You need full-text search (e.g., Elasticsearch) or fuzzy matching (blind indexes support exact matches only).
  • Your team lacks cryptography expertise to manage keys/rotation (though the package simplifies this).
  • You’re using NoSQL (this is database-agnostic but optimized for SQL; test with your schema first).

How to Pitch It (Stakeholders)

For Executives: "This package lets us encrypt sensitive customer data (e.g., emails, payment details) in our Laravel app while keeping search functionality intact—critical for GDPR compliance and reducing breach risks. It’s like putting a vault around our database fields, but with a key we control. The cost? Minimal dev time (uses open-source CipherSweet) and a small performance tradeoff (~10–20ms slower for searches). We can phase this into our roadmap for high-risk data tables first."

For Engineers: *"Spatie’s LaravelCipherSweet wraps CipherSweet, a PHP library for searchable field-level encryption. Here’s the pitch:

  • Why? Encrypt PII (e.g., users.email) at rest while enabling queries like User::whereBlind('email', 'email_index', 'user@example.com').
  • How? Add the UsesCipherSweet trait to models, define encrypted fields in configureCipherSweet(), and run php artisan ciphersweet:encrypt to migrate data.
  • Perks:
    • Blind indexes for exact-match searches on encrypted data.
    • Key rotation via generate-key + re-encryption.
    • Validation with EncryptedUniqueRule for encrypted fields.
  • Tradeoffs: ~10–20ms overhead per encrypted query; requires text columns for encrypted data.
  • Next Steps: Let’s prototype with the users table (encrypt email, add blind index) and benchmark search performance."*

For Security/Compliance Teams: *"This solution addresses:

  1. Data Protection: Encrypts PII at rest (e.g., emails, SSNs) using AES-256-GCM (industry standard).
  2. Query Capability: Blind indexes enable authorized searches without exposing plaintext (e.g., 'Find all active users').
  3. Key Management: Supports rotation (critical for breach response) and secure storage (env vars or files).
  4. Audit Trail: All encryption operations are logged via Laravel’s query log.
  • Risk Mitigation: Even if the database is compromised, encrypted data remains unreadable without our key.
  • Compliance: Aligns with GDPR ‘pseudonymization’ and CCPA ‘encryption’ requirements."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony