Ncrypt : A 2-way encryption library for PHP

I have released Ncrypt, a 2-way encryption library for PHP. Using Ncrypt, you can encrypt a string and decrypt an encrypted string.


1. Include the class

1.a. Option 1 (using Composer)

  • Add the following to your composer.json file-
  • Run composer install command.
  • Include your autoloader file (if not already), like this-

1.b. Option 2

  • Copy class.ncrypt.php file from ncrypt/src/ directory to your project.
  • Include the class in your project file, like this-

2. Instantiate the class

Create an object of the class.

3. Configure (optional)

Optionally set secret key, secret IV and cipher

4.1. How to encrypt a plain text/string

Pass your string to encrypt() method-

4.2. How to decrypt an encrypted string

Pass the already encrypted string to decrypt() method-

Requirement (minimum)

  • PHP 5.3.0
  • php_openssl library needs to be enabled. See here


Disclaimer: This library is NOT guaranteed to be secure enough to use in your serious projects.

Need help with your WordPress tasks?