Disguise Email Addresses for online publishing

I just wrote this quick ASP code to disguise email addresses on web pages. There is a better way to obfuscate email addresses. I recommend creating an image instead of using text in every case, but sometimes a client really wants plain text email address links. There are plenty of websites that will perform the conversion for you, but this morning I decided that was taking entirely too much time.

Here is an ASP classic function that will convert a string to ASCII characters. These characters will display as normal text to the casual user. The difference between alphabet characters and ASCII characters is that encoded characters must be evaluated before they look like an email address. This thin veil of secrecy is enough to fight off some email harvesting robots. Again, using an image is a better solution in most cases, but sometimes using an image is not ideal.


public function asciiDisguise( string )
	build = ""
	for i=1 to len( string )
		build = build & "&#" & asc( mid( string, i, 1 )) & ";"
	next
	asciiDisguise = build
end function

 

I know that my website layout is a bit narrow for some the code I post here, but if you copy and paste the whole block it will work. I will write a PHP (and perhaps javascript) version of this code some time soon and update this post.

UPDATE:

Here is the same function in PHP. After some thought, a Javascript version of this function does not make much sense for the purpose of hiding an email address from email address scraping bots.


function asciiDisguise( $str ){
	$build = "";
	for( $i=0;$i<strlen( $str );$i++ ){
		$build .= "&#" . ord( substr( $str, $i, 1 )) . ";";
	}
	return $build;
}

1 Comment so far

  1. [...] am committed to many other old posts, here. I recently updated my hide email code post. This source code helps you publish emails on web pages while shielding the address from most [...]

Leave a reply

 

Thanks for reading!

You like? Subscribe to my
RSS RSS feed
or

Sign up for email updates:

Some Recent Updates