Obfuscapery
The Obfuscapery email obfuscator combines human interaction, the power of jQuery, and the nearly mystical properties of the XOR bitwise operator. The result is a simple, lightweight and portable plug-in that can be used site-wide with minimal effort without encryption libraries or special PHP builds.
Requirements:
- A website running PHP
- The jQuery library
- This script
How It Works
Click here to see a visual.
- The PHP page includes a script that renders a <div> tag containing each email address, encoded using the Obfuscapery library. Each email link must be enclosed in a specially marked <div> container a well.
- jQuery binds the document to the onMousemove event so that human interaction is required to decode the addresses.
- As soon as a mouse motion is detected, jQuery passes a token to Obfuscapery via AJAX.
- Obfuscapery returns the decode key as the AJAX response.
- jQuery decodes all of the emails on the page and renders them by changing the contents of each email <div> container.
Simple, Elegant and Cool!
What more can you ask from a tidbit of web geekery? Why go to all the trouble? First, just having the XHR return the email does not solve the problem, because a robot could just as easily hit the include script directly. Second, your website's Inbox will thank you. Scroll up to see it in action.
You have to place the Obfuscapery tags into your HTML DOM. Wherever there is an email that needs to be obfuscated, enclose it in a <div> with an id of "mailto_x" where "x" is any integer between 0 and the total number of emails being used. Also, somewhere in the <body> of your page you must include the Obfuscapery PHP include. Here is an example:
<?php include('path/to/obfuscapery/obfuscapery.inc.php'); ?>
Our email: <div style="display:inline" id="mailto_0">loading ...</div>.
Obfuscapery does the rest. When the user moves his or her mouse after the page loads, each default string will be magically replaced by mailto: links. You can customize the actual output from Obfuscapery to suit your needs.
In addition, Obfuscapery only accepts POST data from the local domain, so anyone interested in the key will have to jump through more spoofing hoops than it is worth for your little ol' email address. Your web page, on the other hand, speaks to the utility effortlessly. Read more
Simply drop the Javascript and PHP code into your site's include path and add a script source tag to your pages' <head> block. You can also chop it apart and add it to your JS code manually. Try it for yourself and let us know how it works out.
