-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPasswordManager.php
More file actions
executable file
·52 lines (40 loc) · 1.18 KB
/
PasswordManager.php
File metadata and controls
executable file
·52 lines (40 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace powerauth;
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Responsible for password management e. hashing
* Class PasswordManager
*
* @package POWERCI
* @author Eddilbert Macharia (http://eddmash.com) <edd.cowan@gmail.com>
*/
class PasswordManager{
protected $_plain_password;
public $_password_hash;
public function __construct($password){
$this->_plain_password = $password;
$this->hash_password();
}
/**
* Creates a hash from the provided plain password
*/
protected function hash_password(){
$this->_password_hash = password_hash($this->_plain_password, PASSWORD_DEFAULT);
}
/**
* Verifies the provided plain password matches earlier password
* @param $password
* @return bool
*/
public function verify_password($password){
return password_verify($password, $this->_password_hash);
}
/**
* Verifies the provided hash resulted from the password provided during initialisation
* @param $hash
* @return bool
*/
public function verify_hash($hash){
return password_verify($this->_plain_password, $hash);
}
}