Hide Email Addresses in Web Pages (hideaddr.c)

[ home / software / Hide Email Addresses in Web Pages (hideaddr.c) ]
A very simple command-line utility to encode your email address in the hopes of fooling spammers' address harvesters. Encoding your email address in this way is not a guarantee that address harvesters won't find it. Any of the tricks people use (e.g. "kyle at example dot com") to hide email addresses on web pages are susceptible to smart harvesters, but this has the advantage of looking normal to users through their browsers. Documentation is included as comments within the source file.

I remember reading some time ago a paper that investigated the most common ways that spammers get email addresses. The top item by far was spidering web sites. It also had the quickest time from exposure to receiving spam. I used to pose this question to interview candidates, "What are some ways you could display an email address on a web page, yet prevent spammers from collecting it with harvesters?" I never got what I thought was a really good answer, so this remains my favorite approach. I have no way of knowing whether it works, but I'm going to believe that it does. (Update: I discovered recently that it probably does work, amazing.) An image file with an email address is probably less vulnerable, but this one has the advantage of allowing mailto: links to work still.

[Download file_hideaddr.c]
Compilation should be as simple as

$ cc -o hideaddr hideaddr.c
Let me know if you have any problems or find this useful.

/*++
 * NAME
 *	hideaddr 1
 * SUMMARY
 *	Encodes an email address using HTML numeric character
 *      references.
 * SYNOPSIS
 *	hideraddr <email_address>
 * DESCRIPTION
 *	In order to prevent web-based email address harvesters
 *      from detecting email addresses in web pages, hideaddr
 *      converts an address into the HTML numeric codes for each
 *      character. It prints the numeric character references on
 *      standard output so the code string can be redirected or
 *      cut and pasted into an HTML file.
 *
 *	You need a C compiler to build hideaddr. Type
 *
 *		$ cc -o hideaddr hideaddr.c
 *
 *	Of course, encoding your email address in this way is not
 *	a guarantee that address harvesters won't find it. Any of
 *      the tricks people use (e.g. "kyle at example dot com") to
 *      hide email addresses on web pages are susceptible to smart
 *	harvesters, but this has the advantage of looking normal
 *      to users through their browsers and allowing you to create
 *	hyperlinks for your email addresses.
 *
 *	After you've built the utility, execute it as follows:
 *
 *		$ ./hideaddr kdent@example.com
 *
 *	which will produce a lengthy string like so:
 *
 *	&#107;&#100;&#101;&#110;&#116;&#64;&#101;&#120;&#97;&#109;&#112;&#108;&#101;&#46;&#99;&#111;&#109;
 *
 *	Cut and paste this long string of characters into your
 *	web page. A mailto link should look something like this:
 *
 *	<a href="mailto:&#107;&#100;&#101;&#110;&#116;&#64;&#101;&#120;&#97;&#109;&#112;&#108;&#101;&#46;&#99;&#111;&#109;">
 *	&#107;&#100;&#101;&#110;&#116;&#64;&#101;&#120;&#97;&#109;&#112;&#108;&#101;&#46;&#99;&#111;&#109;
 *	</a>
 *
 *	If this displays unwanted spaces around the address in your
 *	web page, put it all on one line.
 *
 * AUTHOR
 *	Kyle Dent
 *	January 28, 2003
 *--*/

#include <stdio.h>

int
main(int argc, char **argv)
{
	int n;

	if ( argc != 2 ) {
		fprintf(stderr, "Usage: hideaddr <email_address>\n");
		exit(1);
	}

	for ( n = 0; n < strlen(argv[1]); n++ ) {
		printf("&#%d;", argv[1][n]);
	}
	puts("");
}

Bookmark and Share
   
[Back to Top]

Enter a comment or email me directly if you prefer.

Comments:

Name (optional):
Comment: