Download the PHP package weichie-com/blur without Composer
On this page you can find all versions of the php package weichie-com/blur. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download weichie-com/blur
More information about weichie-com/blur
Files in weichie-com/blur
Package blur
Short Description PII detection and de-identification SDK for BeNeLux (Belgium, Netherlands, Luxembourg)
License MIT
Homepage https://github.com/weichie-com/blur
Informations about the package blur
Blur
A data protection and de-identification SDK for BeNeLux (Belgium, Netherlands, Luxembourg) and US identifiers, inspired by Microsoft Presidio.
Features
- Pattern-based PII Detection: Fast and accurate entity recognition using regex patterns
- Full Validation: Checksum validation (Luhn, mod-97, 11-proof) for high accuracy
- BeNeLux-Specific Recognizers:
- π³π± Dutch BSN (Burgerservicenummer) with 11-proof validation
- π§πͺ Belgian National Number with mod-97 validation
- π±πΊ Luxembourg National ID
- BeNeLux IBAN codes with mod-97 checksum
- Phone numbers for BE/NL/LU (using libphonenumber)
- US-Specific Recognizers:
- πΊπΈ Social Security Number (SSN) with area/group/serial validation
- πΊπΈ Individual Taxpayer ID (ITIN)
- πΊπΈ Passport Number (traditional + next-gen)
- πΊπΈ Driver License (multi-state formats)
- πΊπΈ Bank Account Number
- πΊπΈ ABA Routing Number with checksum validation
- Generic Recognizers: Email, Credit Card (Luhn), IP Address, URL
- Multiple Anonymization Strategies:
- Replace with custom values
- Redact (remove completely)
- Mask (partial or full)
- Hash (SHA-256/SHA-512)
- Encrypt/Decrypt (AES-256-CBC)
- Context Enhancement: Boost detection confidence with contextual keywords
- UTF-8 Support: Full multibyte string handling
- Type-Safe: Built with PHP 8.1+ strict types
Installation
Install via Composer:
Or add to your composer.json:
Requirements
- PHP 8.1+ (for strict types and named parameters)
- ext-mbstring: Multibyte string support (UTF-8)
- ext-openssl: AES encryption support
- giggsey/libphonenumber-for-php: Phone number validation (auto-installed)
Quick Start
Usage Examples
1. Detecting BeNeLux National IDs
2. Detecting IBAN Codes
3. Multiple Anonymization Strategies
4. Context Enhancement
Boost detection confidence when context keywords appear near entities:
5. Entity Filtering
Detect only specific entity types:
6. Allow List
Whitelist specific values to ignore:
Supported Recognizers
BeNeLux-Specific
| Entity Type | Description | Validation | Country |
|---|---|---|---|
NL_BSN |
Dutch Burgerservicenummer | 11-proof checksum | π³π± NL |
BE_NATIONAL_NUMBER |
Belgian National Number | mod-97 checksum | π§πͺ BE |
LU_NATIONAL_ID |
Luxembourg National ID | Date validation | π±πΊ LU |
IBAN_CODE |
IBAN (BE/NL/LU) | mod-97 checksum | π§πͺπ³π±π±πΊ |
PHONE_NUMBER |
Phone numbers | libphonenumber | π§πͺπ³π±π±πΊ |
US-Specific
| Entity Type | Description | Validation | Country |
|---|---|---|---|
US_SSN |
Social Security Number | Area/group/serial rules | πΊπΈ US |
US_ITIN |
Individual Taxpayer ID | Format + digit ranges | πΊπΈ US |
US_PASSPORT |
Passport Number | Pattern (context-boosted) | πΊπΈ US |
US_DRIVER_LICENSE |
Driver License | Multi-state patterns | πΊπΈ US |
US_BANK_NUMBER |
Bank Account Number | Pattern (context-boosted) | πΊπΈ US |
US_ABA_ROUTING |
ABA Routing Number | Weighted checksum (mod 10) | πΊπΈ US |
Generic
| Entity Type | Description | Validation |
|---|---|---|
EMAIL_ADDRESS |
Email addresses | RFC validation |
CREDIT_CARD |
Credit card numbers | Luhn checksum |
IP_ADDRESS |
IPv4/IPv6 addresses | IP validation |
URL |
URLs | URL validation |
Supported Operators
| Operator | Description | Parameters |
|---|---|---|
replace |
Replace with custom value | new_value |
redact |
Remove completely | None |
mask |
Partial/full masking | masking_char, chars_to_mask, from_end |
hash |
SHA-256/SHA-512 hashing | algorithm (default: sha256) |
encrypt |
AES-256-CBC encryption | key |
decrypt |
AES-256-CBC decryption | key |
Validation Algorithms
Luhn Checksum (Credit Cards)
Used to validate credit card numbers. Prevents false positives from random digit sequences.
Mod-97 Checksum (IBAN, Belgian National Number)
ISO 7064 mod-97 algorithm for IBAN codes and Belgian National Numbers.
11-Proof Checksum (Dutch BSN)
Dutch "elfproef" (11-check) algorithm for validating BSN numbers.
ABA Routing Checksum (US ABA Routing)
Weighted sum mod-10 algorithm (weights: 3, 7, 1) for validating US ABA routing numbers.
Architecture
Design Principles
- Simple but Complete: Focus on core functionality without ML/NLP complexity
- Pattern-Based: Fast regex matching with validation for accuracy
- Type-Safe: PHP 8.1+ with strict types throughout
- UTF-8 First: Proper multibyte string handling everywhere
- Extensible: Easy to add custom recognizers and operators
- Immutable Results: Thread-safe result objects
Performance
- Fast Pattern Matching: No ML model overhead
- Efficient Validation: Checksum algorithms run in O(n) time
- UTF-8 Optimized: Uses
mb_*functions for correct character offsets - Minimal Dependencies: Only essential libraries (libphonenumber)
Examples
See examples/benelux_example.php for a comprehensive demonstration including:
- All BeNeLux recognizers in action
- Multiple anonymization strategies
- Context enhancement
- Different operator configurations
Run it:
Contributing
Contributions are welcome! To add support for additional countries:
- Create a recognizer in
src/Analyzer/Recognizers/CountryName/ - Extend
PatternRecognizeror implementEntityRecognizer - Add validation logic (checksum, format, etc.)
- Include context words in local language(s)
- Add tests and examples
License
MIT License - See LICENSE file for details
Credits
This project is inspired by Microsoft Presidio. Special thanks to the Presidio team for their excellent work on PII detection and de-identification.
Roadmap
- [x] US-specific recognizers (SSN, ITIN, Passport, Driver License, Bank Account, ABA Routing)
- [ ] Additional country-specific recognizers (Germany, France, Spain, etc.)
- [ ] Custom recognizer builder API
- [ ] Batch processing support
- [ ] Performance benchmarks
- [ ] Integration with popular PHP frameworks (Laravel, Symfony)
Support
For issues, questions, or contributions, please visit the GitHub repository.
All versions of blur with dependencies
ext-mbstring Version *
ext-openssl Version *
giggsey/libphonenumber-for-php Version ^8.13