Spell Email Address For Forums
How can I make the code of the mail to spell it and undetectable for forum when I try to put it in html Thank's anticipated Like this ! but more sophisticated mariabur
Solution 1:
You could use a combination of XOR (w/ random key) and base64/atob.
Though it wont stop a bot which is specifically designed to scrape your forum, see below.
<?php$email = '<a href="mailto:mariaburkke76@gmail.com">mariaburkke76@gmail.com</a>';
functionxor_email($str) {
$key = mt_rand(1, 192);
for ($i = 0; $i < strlen($str); $i++) {
$str[$i] = chr(ord($str[$i]) ^ $key);
}
return$key.'.'.base64_encode($str);
}
$enc = xor_email($email);
?><edata-enc='<?=$enc?>'/><scriptsrc="https://code.jquery.com/jquery-1.12.4.js"></script><script>var decode = function(key, hash) {
var salt = parseInt(key);
var result = '';
for (var i=0; i<hash.length; i++) {
result += String.fromCharCode(salt ^ hash.charCodeAt(i));
}
return result;
}
$(document).find('e').each(function(){
var data = $(this).data('enc').split(".");
$(this).replaceWith(decode(data[0], atob(data[1])));
});
</script>
Would generate the following.
<edata-enc='102.WgdGDhQDAFtECwcPChIJXAsHFA8HBBMUDQ0DUVAmAQsHDwpIBQkLRFgLBxQPBwQTFA0NA1FQJgELBw8KSAUJC1pJB1g='/><scriptsrc="https://code.jquery.com/jquery-1.12.4.js"></script><script>var decode = function(key, hash) {
var salt = parseInt(key);
var result = '';
for (var i=0; i<hash.length; i++) {
result += String.fromCharCode(salt ^ hash.charCodeAt(i));
}
return result;
}
$(document).find('e').each(function(){
var data = $(this).data('enc').split(".");
$(this).replaceWith(decode(data[0], atob(data[1])));
});
</script>
From a harvesters point of view, once determined the method of protection one could easily scrape out the email as followed. Just so you're under no illusions that security through obscurity will not protect you from a custom-made email bot/scraper/harvester.
<?php$html = '<e data-enc=\'102.WgdGDhQDAFtECwcPChIJXAsHFA8HBBMUDQ0DUVAmAQsHDwpIBQkLRFgLBxQPBwQTFA0NA1FQJgELBw8KSAUJC1pJB1g=\'/>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script>
var decode = function(key, hash) {
var salt = parseInt(key);
var result = \'\';
for (var i=0; i<hash.length; i++) {
result += String.fromCharCode(salt ^ hash.charCodeAt(i));
}
return result;
}
$(document).find(\'e\').each(function(){
var data = $(this).data(\'enc\').split("-");
$(this).replaceWith(decode(data[0], atob(data[1])));
});
</script>';
functionxor_email($str, $key) {
for ($i = 0; $i < strlen($str); $i++) {
$str[$i] = chr(ord($str[$i]) ^ $key);
}
return$str;
}
$doc = new DOMDocument();
libxml_use_internal_errors(true);
$doc->loadHTML($html);
//foreach ($doc->getElementsByTagName('e') as$e) {
// parse out XORed string$enc = $e->getAttribute('data-enc');
$enc = explode('.', $enc);
$decoded = xor_email(base64_decode($enc[1]), $enc[0]);
// parse out email$sub_doc = new DOMDocument();
$sub_doc->loadHTML($decoded);
foreach ($sub_doc->getElementsByTagName('a') as$a) {
echo$a->nodeValue;
}
}
Solution 2:
You could use ROT13 simple cipher. It is used to screen out spam bots.
Post a Comment for "Spell Email Address For Forums"