Home arrow PHP arrow PHP Encryption and Decryption Methods

PHP Encryption and Decryption Methods

PHP encryption is a method of obfuscating scripts in such a way that it offers additional protection and prevents unauthorized editing of the scripts. This article discusses both encryption and decryption.

TABLE OF CONTENTS:
  1. PHP Encryption and Decryption Methods
  2. Base 64 Encoding and Compression/Decompression Techniques
  3. PHP Eval Function in Encoding Methods
  4. Case Example: Encoding a Working PHP Script
By: Codex-M
Rating: starstarstarstarstar / 13
November 03, 2009

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

You might have seen encrypted PHP scripts which may look like the one below:

<?php eval(gzinflate(base64_decode('FZfHDoTYEUV/ZXYzIxbkJFseAU1qcg4bi9TknPl64z0SUK/
evef8859///NHcSTdX+VTD78u2Yq/0mQtCOy/
eZGNefHXn0L8kz5jKAueDcZhVNSnh9+OYd6flsK+PCKjqtEnIJoRtF3TO+
GH4UyCIED/st8VD9APjg8Nj+m1ysH0OIjnWTbNnIa+
P4Xyh7gC3XsCCgIOdqVtDlCOaQsau4uAKCI+
aEQxXEg96A4GpOsr85SHX9FcHSL6R+h57gJZzBE872FRE6v7vNdZpzaBU+
GYWOpCnDOMU5n16lgPBE3Qh5ejKZqYA7YSRf3y'))); ?>

If you're interested, you can check out the actual encryption tool for this. In the above example, the complete sets of PHP codes are not visible and are replaced by an obfuscated method of encoding. This article attempts to explain the methods of encrypting and decrypting PHP scripts. One of the popular ways to encrypt scripts is to encode the scripts into another data format such as base 64 encoding.

The decryption process is the exact opposite of the encryption process. The scope of this article covers reversible encryption/decryption processes. Although in PHP it is possible to provide one-way encryption, with techniques such as MD5 encoding, this type of encoding cannot be reversed or decoded. It is ideal for storing passwords in the database, which adds an extra layer of security over storing them in text format. For some differences in the methods, see the screen shot below.

For example, WordPress uses MD5 encoding when storing passwords in the MySQL database. So even if the database has been compromised, the hacker cannot retrieve the actual password (in text format) being used for the admin login.



 
 
>>> More PHP Articles          >>> More By Codex-M
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: