定制 hirasso/html-obfuscator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hirasso/html-obfuscator

Composer 安装命令:

composer require hirasso/html-obfuscator

包简介

Obfuscate emails and phone numbers in HTML using modern web technology

README 文档

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:

<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
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-24