5 class Password extends \Rsi\Fred\User\Authenticator{
10 [
'`~',
'1!',
'2@',
'3#',
'4$',
'5%',
'6^',
'7&',
'8*',
'9(',
'0)',
'-_',
'=+'],
11 [null,
'qQ',
'wW',
'eE',
'rR',
'tT',
'yY',
'uU',
'iI',
'oO',
'pP',
'[{',
']}',
'\\|'],
12 [null,
'aA',
'sS',
'dD',
'fF',
'gG',
'hH',
'jJ',
'kK',
'lL',
';:',
'\'"'], 13 [null,'zZ','xX','cC','vV','bB','nN','mM',',<','.>','/?'] 15 public $strengthCharSets = [ //chars => points 16 'abcdefghijklmnopqrstuvwxyz' => 1, 17 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' => 3, 19 '`~!@#$%^&*()\\-_=+[{]}\|;:\'",<.>/?
' => 10, 20 null => 25 //all other chars 22 public $strengthCharSetChangeScore = 5; 24 protected function check(){ 33 public function hash($password){
34 return password_hash($password,$this->passwordAlgo);
42 public function needsRehash($hash){
43 return password_needs_rehash($hash,$this->passwordAlgo);
52 public function verify($password,$hash){
53 $this->verified(password_verify($password,$hash));
54 return $this->checked;
61 public function known($password){
62 return \Rsi\Record::get($this->component('services
')->password($password),'known'); 69 public function strength($password){
70 $score = $prev_char = $prev_char_set = null;
71 foreach(str_split($password) as $index => $char){
73 if($prev_char !== null) foreach($this->strengthKeyboard as $r => $row) foreach($row as $k => $key) if(strpos($key,$char) !== false){
74 for($i = -1; $i <= 1; $i++) for($j = -1; $j <= 1; $j++) if(($i >= 0) || ($j >= 0))
75 $adjacent .= \Rsi\Record::get($this->strengthKeyboard,[$r + $i,$k + $j]);
76 if(strpos($adjacent,$prev_char) === false) $adjacent = false;
79 if($adjacent) $score++;
82 foreach($this->strengthCharSets as $char_set => $char_set_score) if(!$char_set || (strpos($char_set,$char) !== false)){
83 $score += $char_set_score;
84 if($prev_char_set && ($char_set != $prev_char_set)) $score += $this->strengthCharSetChangeScore;
85 $prev_char_set = $char_set;
known($password)
Check if a password is a 'known' password (found on public available lists).