Log in

View Full Version : base_64 encoding an entire page



olliepop
10-16-2010, 02:16 AM
Hi folks!

Can anybody provide some good tips on mega strong base_64 encoding of an entire page? Perhaps ways to replace characters to make it even harder to decode for the user?

The reason i'm doing this is because i'm doing some freelancing work, and my client at the moment doesn't feel comfortable paying me until the job is 100% done, and he has agreed that it is fair for me to install an encrypted version on his webserver, then once he's confirmed it's all fine he will pay me then i will replace it with the decrypted version.

Thanks guys!
-Ollie

traq
10-16-2010, 03:07 AM
perhaps something like this
<?php

$script = file_get_contents('path/to/script.php');
$encoded = base64_encode($script);
$encodedscript = '$decoded = base64_decode($encoded); eval($decoded);';
file_put_contents('path/to/base64script.php', $encodedscript);

?>? Completely untested.

Honestly, though, this is how it goes: the client pays, then he gets the product. If he wants to see that it works beforehand, maybe you could host a demo for him.

It's not rude or a ripoff. It's practical. If you deliver a script, the client has it. You can't take it back. Even encoding it like this isn't all that helpful. If the client doesn't trust you enough to pay you, that is where the problem is.



This works, with a few restrictions:


<?php

$script = file_get_contents('weird.php');
$encoded = base64_encode($script);
$encodedscript = '<?php $decoded = base64_decode("'.$encoded.'"); eval($decoded); ?>';
file_put_contents('tooweird.php', $encodedscript);

?>

First, I had to fix a few syntax errors. Note, in particular, that $encoded (inside base64_decode()) is now "quoted" correctly.
Second, (assuming this is a php script), the $encodedscript needs to have <?php ?> tags.
Third (and therefore), the script being encoded can not have <?php ?> tags, as they would create a parse error. You might be able to solve that like this:

$encodedscript = '<?php $decoded = '?>'.base64_decode("'.$encoded.'").'<?php'; eval($decoded); ?>';
But I think things are getting silly at this point.