Tag Archives: decryption

Ncrypt : A 2-way encryption library for PHP



1. Include the class

1.a. Option 1 (using Composer)

  • Add the following to your composer.json file-
  • Run composer install command.

1.b. Option 2

  • 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

Link: https://github.com/mukto90/ncrypt


A simple two-way function to encrypt or decrypt a string



So, how to encrypt a string?

Just call this function and pass your string. Additionally set your second parameter to 'e' (optional). To encrypt Hello World!, write-

It’ll generate a encrypted string RTlOMytOZStXdjdHbDZtamNDWFpGdz09

And, how to decrypt?
Pass your encrypted string to the function and set second parameter to 'd'.