You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[](https://packagist.org/packages/ginkelsoft/laravel-encrypted-search-index)
Modern applications that handle sensitive user data—such as healthcare, financial, or membership systems—must ensure that all personally identifiable information (PII) is properly encrypted at rest. However, standard encryption creates a practical challenge: **once data is encrypted, it can no longer be searched efficiently.**
@@ -21,35 +28,35 @@ When data is fully encrypted, you lose the ability to perform meaningful queries
21
28
22
29
This package removes that trade-off by introducing a **detached searchable index** that maps encrypted records to deterministic tokens.
23
30
24
-
---\n
31
+
---
25
32
26
33
## Key Features
27
34
28
-
***Searchable encryption**: Enables exact and prefix-based searches over encrypted data.
29
-
***Detached search index**: Tokens are stored separately from the main data, reducing exposure risk.
30
-
***Deterministic hashing with peppering**: Each token is derived from normalized text combined with a secret pepper, preventing reverse-engineering.
31
-
***No blind indexes in primary tables**: Encrypted fields remain opaque—only hashed references are stored elsewhere.
32
-
***High scalability**: Indexes can handle millions of records efficiently using native database indexes.
33
-
***Laravel-native integration**: Fully compatible with Eloquent models, query scopes, and events.
35
+
***Searchable encryption** — Enables exact and prefix-based searches over encrypted data.
36
+
***Detached search index** — Tokens are stored separately from the main data, reducing exposure risk.
37
+
***Deterministic hashing with peppering** — Each token is derived from normalized text combined with a secret pepper.
38
+
***No blind indexes in primary tables** — Encrypted fields remain opaque; only hashed references are stored elsewhere.
39
+
***High scalability** — Efficient for millions of records through database indexing.
40
+
***Laravel-native integration** — Works directly with Eloquent models, query scopes, and model events.
34
41
35
42
---
36
43
37
44
## How It Works
38
45
39
-
Each model can declare specific fields as searchable. When the model is saved, a background process normalizes the field value, generates one or more hashed tokens, and stores them in a separate database table named `encrypted_search_index`.
46
+
Each model can declare specific fields as searchable. When the model is saved, the system normalizes the field value, generates one or more hashed tokens, and stores them in a separate table named `encrypted_search_index`.
40
47
41
48
When you search, the package hashes your input using the same process and retrieves matching model IDs from the index.
42
49
43
50
### 1. Token Generation
44
51
45
52
For each configured field:
46
53
47
-
***Exact match token:** A SHA-256 hash of the normalized value plus a secret pepper.
48
-
***Prefix tokens:** Multiple SHA-256 hashes representing progressive prefixes of the normalized text (e.g.,`w`, `wi`, `wie`).
54
+
***Exact match token:** A SHA-256 hash of the normalized value + secret pepper.
55
+
***Prefix tokens:** Multiple SHA-256 hashes representing progressive prefixes of the normalized text (e.g. `w`, `wi`, `wie`).
49
56
50
57
### 2. Token Storage
51
58
52
-
All tokens are stored in `encrypted_search_index` with the following structure:
59
+
All tokens are stored in `encrypted_search_index`:
| Database dump or breach | Tokens cannot be reversed (salted + peppered SHA-256).|
84
+
| Statistical analysis | Tokens are detached; frequency analysis yields no correlation.|
85
+
| Insider access | No sensitive data in index table; encrypted fields remain opaque. |
86
+
| Leaked `APP_KEY`|Irrelevant for tokens; pepper is stored separately in `.env`.|
80
87
81
-
The system follows a **defense-in-depth**approach: encrypted data remains fully protected, while token search provides limited, controlled visibility for queries.
88
+
This design follows a **defense-in-depth**model: encrypted data stays secure, while search operations remain practical.
***Chunked rebuilds** for large datasets (`--chunk` option).
167
+
***Queue-compatible** for asynchronous index rebuilds.
163
168
164
-
Unlike in-memory search systems, this index-based approach scales linearly with the size of your dataset and can efficiently handle millions of records.
169
+
The detached index structure scales linearly and supports millions of records efficiently.
165
170
166
171
---
167
172
168
-
## Compliance
173
+
## Framework Compatibility
174
+
175
+
| Laravel Version | PHP Version(s) Supported |
176
+
| --------------- | ------------------------ |
177
+
| 8.x | 8.0 – 8.1 |
178
+
| 9.x | 8.1 – 8.2 |
179
+
| 10.x | 8.1 – 8.3 |
180
+
| 11.x | 8.2 – 8.3 |
181
+
| 12.x | 8.3+ |
169
182
170
-
This approach aligns with major privacy and compliance frameworks:
183
+
The package is continuously tested across all supported combinations using GitHub Actions.
184
+
185
+
---
186
+
187
+
## Compliance
171
188
172
-
* GDPR: Minimal data exposure; encrypted and hashed data separation.
173
-
* HIPAA: Ensures ePHI remains protected even in breach scenarios.
174
-
* ISO 27001: Supports layered security controls for data confidentiality.
189
+
***GDPR** — Encrypted and hashed separation ensures minimal data exposure.
190
+
***HIPAA** — Meets encryption-at-rest requirements for ePHI.
191
+
***ISO 27001** — Aligns with confidentiality and cryptographic control standards.
0 commit comments