﻿ Python check password strength and get suggestions

# Python Cyber Security - Check password strength and get suggestions

## Python Cyber Security: Exercise-7 with Solution

Write a Python program that creates a password strength meter. The program should prompt the user to enter a password and check its strength based on criteria such as length, complexity, and randomness. Afterwards, the program should provide suggestions for improving the password's strength.

The highest strength password that meets the criteria specified in the program will receive a score of 5.

(e.g. at least 8 characters, contains both uppercase and lowercase letters, and at least one number and one special character).

Sample Solution:

Python Code:

import re

score = 0
suggestions = []

# check length
score += 1
else:
suggestions.append("Password should be at least 8 characters long")

# check for uppercase letter
score += 1
else:
suggestions.append("Password should contain at least one uppercase letter")

# check for lowercase letter
score += 1
else:
suggestions.append("Password should contain at least one lowercase letter")

# check for numeric digit
score += 1
else:
suggestions.append("Password should contain at least one numeric digit")

# check for special character
score += 1
else:
suggestions.append("Password should contain at least one special character (!@#\$%^&*(),.?\":{}|<>)")

return score, suggestions

Sample Output:

(5, [])

(4, ['Password should contain at least one lowercase letter'])

(4, ['Password should contain at least one special character (!@#\$%^&*(),.?":{}|<>)'])

(2, ['Password should be at least 8 characters long', 'Password should contain at least one numeric digit', 'Password should contain at least one special character (!@#\$%^&*(),.?":{}|<>)'])

Flowchart:

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.

﻿