Hi, I am trying to protect a fragment of my php code. I will not be using Ioncube, Zend or Codelock, because obviously that will like carrying a book on an 18 wheeler. So as far as I can see the only option is base_64 encryption but then it will be very easy for someone to decipher the actual code. Does anyone have an idea how to use base_64 with a hashkey or salt and suceesfully encrypt the code. For example <?php echo 'Hello World'; ?> will be encoded as <?php eval(gzinflate(base64_decode('encryptedcodewithahash'))); ?> Any help is appreciated. Thank you!
Well, base_64 is always decryptable, saying that so is Ioncube and Zend. My advice is that you keep your SALT in an include file in a root folder not accessible by the web. Here's a stable encryption class i use. include("/var/root/to/your/salt/key.inc.php"); // or $key = "bigcheese"; function encrypt($data) { global $key; $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND); $data = mcrypt_encrypt(MCRYPT_RIJNDAEL_256,$key,$data,MCRYPT_MODE_ECB,$iv); $data = base64_encode($data); return $data; } function decrypt($data) { global $key; $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND); $data = base64_decode($data); $data = mcrypt_decrypt(MCRYPT_RIJNDAEL_256,$key,$data, MCRYPT_MODE_ECB,$iv); return rtrim($data,"\0"); } Code (markup):
Base 64 is NOT encryption, it is encoding. It is just as easily reversed as it is applied. It does not prevent people from seeing what has been encoded, nor was it intended to; quite the opposite. Johnvixen's code doesn't prevent your material from being seen by anyone who has the ability to install PHP files on the server.
you need to use encryption mechanism like zend encoding to encode your files. though it cost a lot of money to get license for zend encoder