1 | <?php |
||
13 | class PasswordProperty extends StringProperty |
||
14 | { |
||
15 | /** |
||
16 | * @return string |
||
17 | */ |
||
18 | public function type() |
||
22 | |||
23 | /** |
||
24 | * Overrides the StringProperty::save() method to ensure the value is encrypted. |
||
25 | * |
||
26 | * If the hash is corruped or the algorithm is not recognized, the value will be rehashed. |
||
27 | * |
||
28 | * @todo Implement proper hashing/rehashing/validation. |
||
29 | * @param mixed $val The value, at time of saving. |
||
30 | * @return string |
||
31 | */ |
||
32 | public function save($val) |
||
44 | |||
45 | /** |
||
46 | * Retrieve the maximum number of characters allowed. |
||
47 | * |
||
48 | * @return integer |
||
49 | */ |
||
50 | public function getMaxLength() |
||
59 | |||
60 | /** |
||
61 | * Determine if the given value is hashed. |
||
62 | * |
||
63 | * If the hash is corruped or the algorithm is not recognized, the value is assumed to be plain-text (not hashed). |
||
64 | * |
||
65 | * @param string $hash The value to test. |
||
66 | * @return boolean |
||
67 | */ |
||
68 | public function isHashed($hash) |
||
73 | |||
74 | /** |
||
75 | * Validates password and rehashes if necessary. |
||
76 | * |
||
77 | * If the hash is corruped or the algorithm is not recognized, the value is assumed to be plain-text (not hashed). |
||
78 | * |
||
79 | * @param string $password A plain-text password. |
||
80 | * @param string $hash A hash created by {@see password_hash()}. |
||
81 | * @return string|boolean |
||
82 | */ |
||
83 | public function isValid($password, $hash) |
||
95 | } |
||
96 |