Obfuscating string values in PHP source code

落爺英雄遲暮 提交于 2019-12-04 05:02:55

问题


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 ....


回答1:


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.




回答2:


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?




回答3:


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


来源:https://stackoverflow.com/questions/5983709/obfuscating-string-values-in-php-source-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!