How to encrypt a PHP file for free?

26,487

Solution 1

Looks like the things you choose are not working this way:

  • Wordpress is open source
  • PHP is not compiled
  • any obfuscation can be decoded

If you don't want to share the source, provide the code as a service. You may require the user to enter API key etc.


  • Execute the code on your server and send response (e.g. JSON or XML) to the Wordpress part.
  • Allow only the users who paid for the service to access the service on your server
  • Authenticate the users by selling and then checking the API key

See: SaaS

Solution 2

Try this one: PHP Encoder

This might be the answer you are looking for.

Solution 3

I don't know your plugin code in specific (and obviously you don't want to make me know it), but keep in mind if you re-use parts of the wordpress codebase in your plugin, your must distribute your code under a compatible license. That means compatible to GPL v2 for the current version.

However this GPL license requires you to provide source code, which specifically means non-obfuscated and non-encrypted. Source-code is the form of a software you use to make modifications to it.

So in your case, encrypting your plugin's code and distributing it could result in a termination of usage rights on the wordpress code for you. This includes the right to create derivates (your plugin) and distribute such derivates (sending your plugin to someone else). Naturally those who will get that plugin do not have any license as well to make use of your derivate.

That's not really an ideal situation if you ask me, especially as once termination of rights is in effect, you must get into contact with every single copyright holder of the wordpress package and ask for re-instatement of rights, something you will be hardly able to.

So take care if you re-use existing code or create derivates that you meet the licensing requirements. Especially if it's about your rights.

IANAL and I can only suggest that next to the technical part like obfuscation/encryption there is also the part of software licensing that can play a role. You just should contact a lawyer and clarify that software licensing situation not that your customers one day demand stuff from you, you never thought about you must deal with. In the end you will have a contract with your customers, so better take care.

Solution 4

What your are looking for is an obfuscator for php. This post may be a duplicate to: Is there a code obfuscator for PHP?

However some words. Contributions to the opensource world like contributing a wordpress plugin may help you more while people are able to read your code.

Solution 5

Since PHP is not compiled. Ioncube and Zend Guard are your only options. Your users will also need to install the loaders for those addons in order to use your code. Which may not be possible in many hosting situations.

Since those plugins are designed to encrypt complete applications, they or may not work with plugins.

Share:
26,487
Joey Morani
Author by

Joey Morani

Updated on July 22, 2022

Comments

  • Joey Morani
    Joey Morani almost 2 years

    I have created a plugin for WordPress although I would like to encrypt it to stop people viewing the source code. I've heard of Zend Guard and IonCube although is there a free alternative to these? Thanks for the help. :)

  • Joey Morani
    Joey Morani almost 13 years
    Ooh, what do you mean by API key? It would be great if they are required to enter a key to use it, which is the reason for encrypting the code anyway.
  • MyXEDNotes
    MyXEDNotes over 11 years
    One way is creating a function that may require a key to complete an encryption or decryption. PHP has its built-in functions like gzdeflate() or gzinflate(), another is using base64_encode()/base64_decode() and str_rot13() or hash() and md5() functions.
  • Marco Demaio
    Marco Demaio about 11 years
    Isn't md5 a non reversable function? How could you obfuscate code with it? $x = 'something'; $h = md5($x); if you know only $h how would you revert back to $x?
  • SaidbakR
    SaidbakR about 10 years
    @MyXEDNotes The website is no longer available.
  • kz_sergey
    kz_sergey almost 7 years
    No. Source encrypting is not obfuscating - it is much better thing. All function, class and variable names don't change, but source code is unavailable.
  • Arshid KV
    Arshid KV almost 5 years
    You can use phpBolt PHP extension. You can download from phpBolt.com