Submit
Path:
~
/
/
opt
/
psa
/
admin
/
plib
/
vendor
/
bjeavons
/
zxcvbn-php
/
src
/
File Content:
Feedback.php
<?php declare(strict_types=1); namespace ZxcvbnPhp; use ZxcvbnPhp\Matchers\MatchInterface; /** * Feedback - gives some user guidance based on the strength * of a password * * @see zxcvbn/src/feedback.coffee */ class Feedback { /** * @param int $score * @param MatchInterface[] $sequence * @return array */ public function getFeedback(int $score, array $sequence): array { // starting feedback if (count($sequence) === 0) { return [ 'warning' => '', 'suggestions' => [ "Use a few words, avoid common phrases", "No need for symbols, digits, or uppercase letters", ], ]; } // no feedback if score is good or great. if ($score > 2) { return [ 'warning' => '', 'suggestions' => [], ]; } // tie feedback to the longest match for longer sequences $longestMatch = $sequence[0]; foreach (array_slice($sequence, 1) as $match) { if (mb_strlen($match->token) > mb_strlen($longestMatch->token)) { $longestMatch = $match; } } $feedback = $longestMatch->getFeedback(count($sequence) === 1); $extraFeedback = 'Add another word or two. Uncommon words are better.'; array_unshift($feedback['suggestions'], $extraFeedback); return $feedback; } }
Edit
Rename
Chmod
Delete
FILE
FOLDER
INFO
Name
Size
Permission
Action
Matchers
---
0755
Math
---
0755
Feedback.php
1504 bytes
0644
Matcher.php
3524 bytes
0644
Scorer.php
10074 bytes
0644
TimeEstimator.php
3403 bytes
0644
Zxcvbn.php
2217 bytes
0644
N4ST4R_ID | Naxtarrr