Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Created by PhpStorm.
- * User: ehiag
- * Date: 5/17/2016
- * Time: 3:53 AM
- */
- require_once('../thirdparty/PasswordLib/bootstrap.php');
- use PasswordLib\PasswordLib as passwordLib;
- class password
- {
- public $cost = 8 ;//4 to 31
- public $algo;
- private $passwordLib;
- public function __construct()
- {
- $this->algo = '$2y$'; // prefix for PASSWORD_BCRYPT
- $this->passwordLib = new passwordLib();
- }
- public function create_password_hash($password)
- {
- $pass = trim($password);
- $hash = $this->passwordLib->createPasswordHash($pass,$this->algo,array('cost'=>$this->cost)); //create the hash of the user-supplied password
- return $hash;
- }
- public function password_verify($password,$hash)
- {
- $is_valid = $this->passwordLib->verifyPasswordHash($password, $hash);
- if ($is_valid){
- return true;
- }else{
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement