Tag Archives: decryption

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

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

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

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

Update: I have released Ncrypt, a library (OOP based) that facilitates the same (two-way encryption and decryption). See here

This function will provide you a two-way system to encrypt a string or decrypt an encrypted 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'.