For a secured system, most of the data is encrypted in server end and sent to database. And after fetching the data from database, just decrypt before showing in front end.

There are lots of procedure to encrypt the data, lots of encryption algorithm out there. But, here we will use a simple encryption method though it’s powerful 🙂

We are going to use mcrypt library of php for this method. You can install the library following the instruction below: (based on Ubuntu)

Once you install mcrypt, you are free to use the library. Here is the code that you need to include in your project:

The usage is already in the above gist. But again, just instantiate the class, pass the data you want to encrypt, do whatever you want. Then when needed, fetch and decrypt:

You may also read:  Team Bio – Meet the Team – WordPress Plugin

Happy coding! 🙂

Leave a Reply