1

I want to protect PHP source code at easy way.

here is a example.

 $a = "\x46\122" . chr(578813952>>23) . "" . chr(0105) . "\x2d"; 
 $b = "\x73" . chr(847249408>>23) . "" . chr(0162) . "\x69" . chr(0141) . "" . chr(905969664>>23) . ""; 
 $c = "" . chr(0x53) . "" . chr(0105) . "\x52\x56" . chr(0105) . "\x52" . chr(796917760>>23) . "\x4e" . chr(545259520>>23) . "\x4d" . chr(0x45) . "";

it is.

$a="FREE-";
$b="serial";
$c="SERVER_NAME";

Please help me someone to convert this type of string ??

There is 3 type of encryption.

Type[1] : "\x46\122"
Type[2] : chr(0105)
Type[3] : chr(578813952>>23)

Please help me to create a convert function...from PHP string.

thank you !

------------------------ I update question-------------------

OK... I should change question..

I want to create a function.

function1.

$a = "FREE-";
echo function1($a);

---> output

"\x46\122" . chr(578813952>>23) . "" . chr(0105) . "\x2d";

in this function, Function use 3 type of logic at random. here is 3 type.

Type[1] : "\x46\122"
Type[2] : chr(0105)
Type[3] : chr(578813952>>23)

Could you help me ....

3
  • 7
    Just note: If I receive your script and insert a simple var_dump($a); var_dump($b); var_dump($c); your whole protection is gone. Commented May 12, 2011 at 20:04
  • 5
    +1 because I think the question is well-asked; even questions about bad ideas can be asked either well or poorly, and this one has clear goals. Silly goals, but goals. :) Commented May 13, 2011 at 1:35
  • what's the problem to use a real obfuscator? Commented Jul 9, 2011 at 0:01

3 Answers 3

29

This is a, frankly, stupid way of "protecting" your code. Hopefully you realize that once the code is delivered to the clients, they can simply undo all of this and extract the values themselves?

Use legal means to protect the code. "here's my code, you are not allowed to share it. If you do, I get $50 kazillion dollars and the Droit de Seigneur with your most beautiful daughter, or an extra 200 kazillion in lieue if they're all ugly".

An iron-clad licensing agreement will be far better protection than any cereal-box decoder-ring wet kleenex method you care to apply ever will be.

Sign up to request clarification or add additional context in comments.

5 Comments

A nicer way would just be to develop a PHP mod :)
ok... I understand. but please help me , How to convert with php.
I want to create 3 type of function for type[1,2,3].... i know this will not proctect source code... I need power of this comminity. I can not create the functions.
@user751234: What want you to achieve with this functions, if its not pseudo-protection? Maybe you should update your question to make clear, whats going on here.
+1 for the Droit de Seigneur. (Isn't that some kind of dog? :)
9

For further suggestions why this is a waste of your time:

Asked at 8:36, decoded at 8:44. Eight minutes of protection: https://stackoverflow.com/questions/5456462/what-does-this-php-code-do

Asked at 11:01, decoded at 11:17, and very-well analyzed at 11:47. Hacked, what does this piece of code do?

In the first case, I'm willing to bet the majority of the fastest poster's time was spent writing. So feel confident that however you try to obfuscate your code, it'll take only three or four minutes to undo whatever it is you've done.

How much time are you willing to put into obfuscating your code when it'll take someone only a few minutes to undo what you've done? Could that time have been better spent writing awesome features that your customers would love?

1 Comment

What if you salt it? And no one sees the salting
4

ord will get you a character's ASCII value, using that we can generate the 3 things you want.

Type 1: Use dechex to convert int to hex.

$chr = 's';
$hex = dechex(ord($chr)); // 73

Type 2: Use decoct to convert into to octal.

$chr = 'E';
$oct = decoct(ord($chr)); // 105

Type 3: Use the << (shift left) operator.

$chr = 'e';
$bin = ord($chr)<<23; // 847249408

2 Comments

:) T H A N K Y O U , V E R Y M U C H I will try to contribute this community , next time.
As @Marc and @KingCrunch have said, using this to "protect" your program's source code is not the best idea.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.