hirasso/html-obfuscator
Composer 安装命令:
composer require hirasso/html-obfuscator
包简介
Obfuscate emails and phone numbers in HTML using modern web technology
README 文档
README
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:
<html-obfuscator-obfuscated value="..." key="..."></html-obfuscator-obfuscated>
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.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-24