I have written a php function that decode the protected email based on this answer
I took this function
def decodeEmail(e):
de = ""
k = int(e[:2], 16)
for i in range(2, len(e)-1, 2):
de += chr(int(e[i:i+2], 16)^k)
return de
converted to php :
function decode($e){
$de= "";
$c = substr($e,0,2);
$k = hexdec($c);
foreach(range(2, strlen($e)-1, 2) as $i => $v){
$s = substr($e,$i,$i+2);
$d = hexdec($s);
$de .= chr($d^$k);
}
return $de;
}
the function works almost except the last three characters, sometimes two, sometimes one.
sample :
given value
caaba0a3bea28af9fcfabfabaeb9e4a9a5a7
it returns
ajith@360uads���
the correct result should be
[email protected]
what did I do wrong in my function ? what did I miss from the original python function ?
My Answer:
base64.b64decode(e).decode('utf-8') return de__and converted it to php function as follows:function decodeEmail($e){ $de = base64_decode($e); return $de;}You can use this php function to decode the protected email in your scraping script.
Rate this post
3 of 5 based on 2711 votesComments