-
-
Notifications
You must be signed in to change notification settings - Fork 46.7k
Added check_strong_password.py #4950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'd suggest modify the current https://github.com/TheAlgorithms/Python/blob/master/other/password_generator.py. As it's more relevant and provides more functionalities. This looks good but if we put these together, it may be better!
Related PR #4873 |
other/check_strong_password.py
Outdated
import re | ||
|
||
|
||
def strong_password_detector(password: str) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def strong_password_detector(password: str) -> str: | |
def strong_password_detector(password: str, min_length: int = 8) -> str: |
and make appropriate changes in the function.
other/check_strong_password.py
Outdated
'Password should contain UPPERCASE, lowercase, numbers, special characters' | ||
""" | ||
|
||
upper = re.compile(r"[A-Z]") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would upper = any(char in string.ascii_uppercase for char in password)
be faster or slower?
other/check_strong_password.py
Outdated
if re.compile(r"\s").search(password) or len(password) < 8: | ||
return "Your Password must be at least 8 characters long" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move these lines before line 22 so that we do not do the work on lines 22-24 if the password is too short.
>>> strong_password_detector('Sh0r1') | ||
'Your Password must be at least 8 characters long' | ||
|
||
>>> strong_password_detector('Hello123') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the tests should be a long (like 20 char) string. Also tests for strong_password_detector(0), strong_password_detector(1.3), strong_password_detector(['H', 'w', 'e', 'a', '7', '$', '2', '!'])
* Added check_strong_password.py * Corrected Comment * Updated * Updated check_strong_password.py * Ran Pre-Commit
Describe your change:
It checks whether a giving password is strong or not
Checklist:
Fixes: #{$ISSUE_NO}
.