Detectors
SIREN
Detect and validate French business identification numbers with Luhn checksum.
Purpose
Use the siren detector for French business identification numbers (SIREN — Système d'Identification du Répertoire des Entreprises).
Detector Name
sirenSupported Formats
- 9 digits:
552120222
SIREN is always exactly 9 digits.
Validation Logic
- Require exactly 9 digits.
- Run the Luhn checksum algorithm.
Checksum Algorithm (Luhn)
- Starting from the rightmost digit, double every second digit.
- If doubling produces a number greater than 9, subtract 9.
- Sum all digits.
- The total must be divisible by 10.
Python Examples
Explicit Engine (Recommended)
from fastpii import FastPII
from fastpii.countries.fr import FrenchPack
priority = {"siren": 100, "email": 70, "name": 50, "phone": 20}
engine = FastPII(priority=priority)
engine.register(FrenchPack())
result = engine.detect("SIREN: 552120222", detector_names=["siren"])Convenience API
from fastpii import PrivacyGuard
guard = PrivacyGuard(regions=["fr"])
result = guard.validate("552120222", "siren")
print(result.is_valid)Convenience API — Detect in free text
from fastpii import PrivacyGuard
guard = PrivacyGuard(regions=["fr"])
result = guard.detect("SIREN: 552120222")
for finding in result.findings:
print(finding.type, finding.value)Limitations
- SIREN is specific to French business identification.
- The detector requires context words like "SIREN" or nearby business terms to reduce false positives on other 9-digit numbers.