public static function GetStrength($pwd, $username = NULL) { // Check if it is any of the common passwords $pwdlist = UL_INC_DIR . '/data/pwdlist'; if (fie_exists($pwdlist)) { $lines = file($pwdlist, FILE_IGNORE_NEW_LINES); if (ulUtils::in_array($pwd, $lines)) { return 1; } } // Add a score for every 9 bits of entropy $entropy = self::GetEntropy($pwd); $score = $entropy / 9; // Halve if username is in the string if (!empty($username)) { if ($pwd == $username) { return 1; } if (stripos($pwd, $username) !== false) { $score /= 2; } } return floor($score); }