DISCLAIMER: I do not own any of the source codes provided below. This is only a tutorial on how to install CodeIgniter-Phpass-Library in your CodeIgniter applications. If you want to see the original tutorial, please go to this link: https://github.com/jenssegers/CodeIgniter-Phpass-Library
phpass is a portable password hashing framework for use in PHP applications. The preferred (most secure) hashing method supported by phpass is the OpenBSD-style bcrypt (known in PHP as CRYPT_BLOWFISH), with a fallback to BSDI-style extended DES-based hashes (known in PHP as CRYPT_EXT_DES), and a last resort fallback to an MD5-based variable iteration count password hashing method implemented in phpass itself.
- Download this .zip file: https://github.com/jenssegers/CodeIgniter-Phpass-Library/archive/master.zip
- From the downloaded files, copy the libraries and vendor folder into your CodeIgniter application folder.
- Copy the phpass.php from the config folder of your download files and paste in your CodeIgniter's application/config folder.
- Please follow the instructions below on how to use this hash library.
<?php
// Load the hash library
$this->load->library('phpass'); // or use spark
// example 1: hashing a password
$password = $this->input->post('password');
$hashed = $this->phpass->hash($password);
// example 2: checking a password
$user = $this->user_model->get(123);
$hashed = $user->password;
$password = $this->input->post('password');
if ($this->phpass->check($password, $hashed))
echo 'logged in';
else
echo 'wrong password';
?>