Skip to content

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

Merged
merged 6 commits into from
Oct 20, 2021
Merged

Conversation

Snimer
Copy link
Contributor

@Snimer Snimer commented Oct 3, 2021

Describe your change:

It checks whether a giving password is strong or not

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

@ghost ghost added awaiting reviews This PR is ready to be reviewed tests are failing Do not merge until tests pass labels Oct 3, 2021
@ghost ghost removed the tests are failing Do not merge until tests pass label Oct 3, 2021
Copy link
Member

@poyea poyea left a 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!

@poyea poyea self-assigned this Oct 4, 2021
@poyea
Copy link
Member

poyea commented Oct 4, 2021

Related PR #4873

@poyea poyea mentioned this pull request Oct 4, 2021
14 tasks
import re


def strong_password_detector(password: str) -> str:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

'Password should contain UPPERCASE, lowercase, numbers, special characters'
"""

upper = re.compile(r"[A-Z]")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 26 to 27
if re.compile(r"\s").search(password) or len(password) < 8:
return "Your Password must be at least 8 characters long"
Copy link
Member

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')
Copy link
Member

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', '!'])

@ghost ghost added awaiting changes A maintainer has requested changes to this PR and removed awaiting reviews This PR is ready to be reviewed labels Oct 4, 2021
@ghost ghost added awaiting reviews This PR is ready to be reviewed and removed awaiting changes A maintainer has requested changes to this PR labels Oct 20, 2021
@ghost ghost added the tests are failing Do not merge until tests pass label Oct 20, 2021
@ghost ghost removed the tests are failing Do not merge until tests pass label Oct 20, 2021
@ghost ghost removed the awaiting reviews This PR is ready to be reviewed label Oct 20, 2021
@cclauss cclauss added hacktoberfest hacktoberfest-accepted Accepted to be counted towards Hacktoberfest labels Oct 20, 2021
@cclauss cclauss merged commit c886a66 into TheAlgorithms:master Oct 20, 2021
shermanhui pushed a commit to shermanhui/Python that referenced this pull request Oct 22, 2021
* Added check_strong_password.py

* Corrected Comment

* Updated

* Updated check_strong_password.py

* Ran Pre-Commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest hacktoberfest-accepted Accepted to be counted towards Hacktoberfest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants