Cyber SecurityMediumOutputAuthentication

Password Strength Meter

Turn character pools and length into entropy bits, add a common-password blacklist, and rate each password like a real sign-up form would.

100 ptsEstimated time: 20 min

Statement

The story

The sign-up form of your startup needs a strength meter, and the security lead wants one that is based on entropy rather than "has a symbol". You are writing the scoring engine as a standalone program: passwords in, scores out.

Input

The first line is N (1 ≤ N ≤ 100). Then come N lines, one password per line. Passwords are printable ASCII (letters, digits, punctuation and spaces inside the text), are at most 200 characters long and never start or end with a space. A password can be empty (an empty line).

Rules

  1. Pool size. Start at 0 and add 26 if the password contains a lowercase letter, 26 for an uppercase letter, 10 for a digit and 33 if it contains any other character (punctuation or a space; those count once, together).
  2. Entropy in bits is length × log2(pool). An empty password has 0 bits.
  3. Blacklist. If the password, compared case-insensitively, is one of password, 123456, 12345678, qwerty, abc123, letmein, iloveyou, admin, its entropy is 0 whatever rule 2 says: attackers try these first.
  4. Rating from the exact (unrounded) entropy: below 28 is very weak, below 36 weak, below 60 reasonable, below 128 strong, otherwise very strong.

Output

For each password print one line: the entropy rounded to one decimal place, a space, and the rating.

Examples

Input:

3
hunter2
correct horse battery staple
PASSWORD

Output:

36.2 reasonable
164.7 very strong
0.0 very weak

hunter2 uses lowercase and a digit (pool 36), so 7 × log2(36) ≈ 36.2. The passphrase uses lowercase letters and spaces (pool 59), so 28 × log2(59) ≈ 164.7. PASSWORD is blacklisted.

Input:

2
Tr0ub4dor&3
abc

Output:

72.3 strong
14.1 very weak

Input:

1
123456789012

Output:

39.9 reasonable

Entropy assumes every character is drawn uniformly at random from the pool, which people never do. That is why real systems also check blacklists, and why length buys more than "complexity" rules.

Sample input

3
hunter2
correct horse battery staple
PASSWORD

Hints

Stuck? Hints are optional, and each one lowers the points you earn for solving this challenge.

  1. Hint 1Costs 8 points

    Sign in to reveal hints.

  2. Hint 2Costs 12 points

    Reveal the previous hint first

  3. Hint 3Costs 15 points

    Reveal the previous hint first

Lessons that teach this

Stuck on the ideas rather than the puzzle? These lessons cover what you need.