Showing posts with label cool. Show all posts
Showing posts with label cool. Show all posts

Wednesday, May 28, 2008

Cool Python way to beat email harvesting bots

This was so cool -I really had to share it. I found this here while reading up about creating Python extensions using swig. The author uses Python list comprehensions along with chr() and ord() to generate contact email addresses.

Suppose your email address was user@somerandomwebsite.com (SPAM THAT !) . Here is what you would do to generate the correct string sequence for this email address.

>> ''.join([chr(ord(c)+2) for c in 'user@somerandomwebsite.com'])
wugtBuqogtcpfqoygdukvg0eqo


Now stick this back into the previous list comprehension as follows

>> ''.join([chr(ord(c)-2) for c in 'wugtBuqogtcpfqoygdukvg0eqo'])
user@somerandomwebsite.com

I guess such a link on your web page would prevent or at least dissuade anyone except an intermediate Python programmer from trying to contact you - which may or may not be what you want !