I'm creating an application that requires passing email addresses around in querystrings and linking to these pages in public documents.
I'd like to prevent my site from becoming spambot heaven, so I'm looking for a simple algorithm (preferably in JavaScript) to encrypt/obfuscate the address so it can be used publicly ina URL without making the email address an easy target.
ex
www.mysite.com/[email protected]
to
www.mysite.com/page.php?e=aed3Gfd469201
Preferably the result would be a short-ish string that could easily be used in a URL. Any suggestions for what algorithm I could use?
Address munging is the practice of disguising an e-mail address to prevent it from being automatically collected by unsolicited bulk e-mail providers.
By enabling Cloudflare Email Address Obfuscation, email addresses on your web page will be obfuscated (hidden) from bots, while keeping them visible to humans. In fact, there are no visible changes to your website for visitors.
It obfuscates (scrambles) email addresses in HTML to prevent bots from scraping them from your site.
RSA-encrypt the data using the public key corresponding to a private key held only by your site.
Base64 and urlencode the result.
you can make a simple function, which would xor each char value with some integer, and make a hex encoded string. (email addresses do not contain non-ascii characters, so it won't complicate with multibyte chars). e.g.:
obfusc = function(s, c) {
c = c || 0x7f;
r = "";
for (i in s) {
valh = (s.charCodeAt(i) ^ c).toString(16);
if (valh.length == 1) valh = "0" + valh;
r += valh;
};
return r;
}
deobfusc = function(s, c) {
c = c || 0x7f;
r = "";
for (var i=0; i<(s.length/2); i++) {
r += String.fromCharCode(parseInt(s.substr(i*2, 2), 16) ^ c)
};
return r;
}
addr = "[email protected]";
x = obfusc(addr);
alert(addr + " -> " + x + " -> " + deobfusc(x))
// [email protected] -> 15101a3f1a071e120f131a511c1012 -> [email protected]
Some options coming to my mind :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With