fucking javascript is pissing me off. Anyone help wiht some basic encryption?

So basically i need to encrypt one html line.

Let’s say it’s a link, so <a href="http://google.com">google</a>

Thing is, the href or src is actually a php variable which changes, so it’d actually be

<a href="<?php $website;?>">google</a>

How can i go about encrypting this into javascript?

Maybe I’m missing something or I’m a bit rusty or I’m just dumb, but I honestly have no idea what you mean by "encrypt." What sort of encryption are you talking about?

kinda like this

It encrypts the link i had into

<Script Language=’Javascript’>
<!– HTML Encryption provided by iWEBTOOL.com –>
<!–
document.write(unescape(‘%3C%61%20%68%72%65%66%3D% 22%68%74%74%70%3A%2F%2F%67%6F%6F%67%6C%65%2E%63%6F %6D%22%3E%67%6F%6F%67%6C%65%3C%2F%61%3E’));
//–>
</Script>

i need something like that, but kind of "on the fly" if you know what i mean

There might be more efficient ways of doing it, but this is what I came up with. Similar functions like urlencode make exceptions for certain characters. My method will leave no stone unturned. lol

<?php
$urls = Array('http://google.com/', 'http://yahoo.com', 'http://nambla.org');

$out = <<<DUMPYDOOBYISAWESOME
<script type="text/javascript">
//<![CDATA[
document.write(unescape('
DUMPYDOOBYISAWESOME;

foreach ($urls as $url) {
	$chars = Array();
	$url = '<a href="'.$url.'">'.$url.'</a><br />';
	for ($i=0;$i<strlen($url);$i++) { $chars[] = $url[$i]; }
	while (list($key, $val) = each($chars)) {
		$chars[$key]='%'.dechex(ord($chars[$key]));
	}
	$out.=implode('',$chars);
}
$out.=<<<DUMPYDOOBYISAWESOME
'));
//]]>
</script>
DUMPYDOOBYISAWESOME;

echo $out;

Output:

<script type="text/javascript">
//<![CDATA[
document.write(unescape('%3c%61%20%68%72%65%66%3d%22%68%74%74%70%3a%2f%2f%67%6f%6f%67%6c%65%2e%63%6f%6d%2f%22%3e%68%74%74%70%3a%2f%2f%67%6f%6f%67%6c%65%2e%63%6f%6d%2f%3c%2f%61%3e%3c%62%72%20%2f%3e%3c%61%20%68%72%65%66%3d%22%68%74%74%70%3a%2f%2f%79%61%68%6f%6f%2e%63%6f%6d%22%3e%68%74%74%70%3a%2f%2f%79%61%68%6f%6f%2e%63%6f%6d%3c%2f%61%3e%3c%62%72%20%2f%3e%3c%61%20%68%72%65%66%3d%22%68%74%74%70%3a%2f%2f%6e%61%6d%62%6c%61%2e%6f%72%67%22%3e%68%74%74%70%3a%2f%2f%6e%61%6d%62%6c%61%2e%6f%72%67%3c%2f%61%3e%3c%62%72%20%2f%3e'));
//]]>
</script>

If you need help deciphering it, let me know.

thanks a ton dude.

i’ll try it out in a bit and report back

works perfectly

thanks man

sorry to barge in but can i ask why you wanted the link encrypted?

He might be making his e-mail address publicly available and doesn’t want text browsers (read: bots) to read it.

ooooo that never occurred to me!

I will prob use this script, so thanks!!

If you need help deciphering it, let me know.

Holy shit i was actually passively looking for this, works fantastic thank you