Browser Fingerprint Hash Regex for PHP
/^[0-9a-f]{32}$|^[0-9a-f]{64}$/iWhat this pattern does
This page provides a lightweight, single-purpose regular expression for matching browser fingerprint hash, ported and verified for PHP. Identity and credential patterns need both correctness and safety, since they're frequent targets for adversarial input. The snippet below is ready to drop into your PHP project — whether you're validating in a Laravel validator, a WordPress plugin, or a standalone PHP script.
Php Implementation
<?php
// Browser Fingerprint Hash
// ReDoS-safe | RegexVault — Identity & PII > Digital Identity
define('BROWSER_FINGERPRINT_HASH_PATTERN', '/^[0-9a-f]{32}$|^[0-9a-f]{64}$/');
function validate_browser_fingerprint_hash(string $input): bool {
return (bool) preg_match(BROWSER_FINGERPRINT_HASH_PATTERN, $input);
}
// Example
var_dump(validate_browser_fingerprint_hash("d41d8cd98f00b204e9800998ecf8427e")); // bool(true)Test Cases
Matches (Valid) | Rejects (Invalid) |
|---|---|
d41d8cd98f00b204e9800998ecf8427e | d41d8cd98f00b204e9800998ecf8427 |
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 | d41d8cd98f00b204e9800998ecf8427eXX |
| — | ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
When to use this pattern
This pattern is drawn from the Identity & PII > Digital Identity category and carries a ReDoS-safe certification. That matters for PHP developers because especially relevant in PHP where PCRE backtracking limits can trigger silent failures on malicious input. RegexVault audits patterns against known backtracking attack vectors, ensuring you have the necessary context before using this regex in a high-stakes production environment.
Common Pitfalls
Fingerprinting is treated differently from cookies by regulators — it is harder to opt out of and more persistent. The ICO (UK) and CNIL (France) have specifically ruled fingerprinting requires consent.
Technical Notes
Browser fingerprinting combines canvas, WebGL, fonts, plugins, and device characteristics into a hash. Under GDPR recital 30, fingerprinting constitutes tracking. Under ePrivacy Directive, it requires consent. 32 chars = MD5, 64 chars = SHA-256.
Have a pattern that belongs in the vault?
Submit it for review — community-verified patterns get credited to your GitHub handle. Free submissions join the queue. Priority review available for $15.
Submit a Pattern