Forum Moderators: coopster

Message Too Old, No Replies

Encrypting a javascript in PHP

Is it possible?

         

sauce

7:34 pm on Nov 7, 2005 (gmt 0)

10+ Year Member



I have tracking javascript that I have on all my sites that I want to encrypt to it can't be viewed in the source code... Is this possible?

Would this do it?

<?php
$string = "<script language=\"javascript\" type=\"text/javascript\"
src=\"http://www.domain.com/track.php\">
</script>
<noscript>
<img width=\"1\" height=\"1\" border=\"0\"
src=\"http://www.domain.com/track.php?rep=v&transport=img\" />
</noscript>";

function encrypt($string) {
for($i=0;$i<strlen($string);$i++) {
$ENCRYPTED .= chr(ord($string{$i})-13);
}
return $ENCRYPTED;
}
function decrypt($string) {
for($i=0;$i<strlen($string);$i++) {
$DECRYPTED .= chr(ord($string{$i})+13);
}
return $DECRYPTED;
}
$ENCRYPTED = encrypt($string);
$DECRYPTED = decrypt($ENCRYPTED);
?>

chirp

9:52 am on Nov 8, 2005 (gmt 0)



The browser has to able to read it, and therefore has to download it, and therefore anyone can download/read it by pretending to be a browser.