Example #1
0
 /**
  * Works with Myth\Auth\Password to enforce a strong password.
  * Uses settings from the auth config file.
  *
  * @param $password
  */
 function isStrongPassword($password)
 {
     $min_strength = config_item('auth.min_password_strength');
     $use_dict = config_item('auth.use_dictionary');
     $strong = \Myth\Auth\Password::isStrongPassword($password, $min_strength, $use_dict);
     if (!$strong) {
         if (isset(get_instance()->form_validation)) {
             get_instance()->form_validation->set_message('isStrongPassword', lang('auth.pass_not_strong'));
         }
         return false;
     }
     return true;
 }
Example #2
0
 public function testIsStrongWithDictionary()
 {
     $result1 = Password::isStrongPassword('asinine', 18, true);
     $result2 = Password::isStrongPassword('aaaaaaa', 18, true);
     $result3 = Password::isStrongPassword('Aalesund', 18, true);
     // Dictionary word
     $result4 = Password::isStrongPassword('correcthorse', 18, true);
     // bits = 21.5
     $result5 = Password::isStrongPassword('correcthorse', 25, true);
     // bits = 21.5
     $result6 = Password::isStrongPassword('CorrectHorse123!*!', 25, true);
     // bits = 30.7
     //        $score2 = Password::getNISTNumBits('correcthorse', true);
     //        die(var_dump($score2));
     $this->assertFalse($result1);
     $this->assertFalse($result2);
     $this->assertFalse($result3);
     $this->assertFalse($result4);
     $this->assertFalse($result5);
     $this->assertTrue($result6);
 }