Cygnite - A Modern Toolkit For Web Developers

The Elegant Way of Building Full-Featured Web Applications

Cygnite Dynamic Routing

Encryption & Hashing

Documentation

Encryption

Configuration

You can configure encryption parameters in the src/Apps/Configs/application.php file. Default encryption key has been set in the same file. However we encourage to change it for your application. Encryption library uses mcrypt extension for encrypting value.


  'cf_encryption_key'  => 'cygnite-shaXatB.............59c4mrez',


[Note: Make sure mcrypt extension installed in your system to use encryption.]

Encrypting A String

Encryption library uses salt key to store your data securely. You can encrypt a string as below.


   $crypt = new \Cygnite\Common\Encrypt();
   $encryptedString = $crypt->encode("Hello Peter");


Decrypting A Encrypted String

You can decrypt encrypted value using decode method.


    echo $crypt->decode($encryptedString);

Hashing

Cygnite provides secure Bcrypt hashing for storing user passwords. Bcrypt hashing is a better choice over encryption library.

Creating Password Hash


   use Cygnite\Hash\Hash;

   $hash = Hash::instance();
   $hashedPassword = $hash->create('Your-New-Password');

Verifying Password Against Hash



   if ($hash->verify('password', $hashedPassword)) {
    // The passwords match...
   }

Check If Password Need To Rehashed



   if ($hash->needReHash($hashed)) {
      $hashed = $hash->create('plain-string');
   }

Follow Us On Facebook Twitter Google+ Linkedin
Released Under The MIT Public License. Copyrights @2012-2017. Powered by- Sanjoy Dey Productions.