hirasso/html-obfuscator

Obfuscate emails and phone numbers in HTML using modern web technology

Maintainers

Package info

github.com/hirasso/html-obfuscator

pkg:composer/hirasso/html-obfuscator

Fund package maintenance!

hirasso

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 1

v0.0.1 2026-06-24 11:26 UTC

This package is auto-updated.

Last update: 2026-06-24 14:10:47 UTC


README

Latest Version on Packagist Test Status Code Coverage

Obfuscate emails and phone numbers in HTML using modern web technology

Why

You might think that obfuscation won't work on spam bots. Turns out it does if done right!

How it works

On the server, PHP finds emails and phone numbers in the HTML, XOR-encodes them with a key derived from a passphrase (MD5 of a shuffled version of it), base64-encodes the result, and replaces the original text with a custom HTML element:

<obfuscated-element value="..." key="..."></obfuscated-element>

In the browser, a Web Component registered under that tag name picks up each element on connectedCallback, reverses the XOR encoding, and swaps itself out with the decoded content. Spam bots crawling the raw HTML never see the actual email or phone number.

Features

  • Fluent API
  • Fully compatible with HTML5
  • All mutations are lazily queued and processed in one go
  • Extensively tested

Installation

# requires PHP >= 8.4
composer require hirasso/html-obfuscator

Minimal Example

use Hirasso\HTMLObfuscator\HTMLObfuscator;

echo HTMLObfuscator::createFromString($html)->render();

Maximal Example

use Hirasso\HTMLObfuscator\HTMLObfuscator;

echo HTMLObfuscator::createFromString($html)
    ->phoneNumbers(false)
    ->passphrase('nobody will guess this!')
    ->render();

→ Browse the tests folder for more usage examples.