Skip to content
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

Create Password_Strong_weak.py #1638

Merged
merged 1 commit into from
Oct 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import re


# Function to categorize password
def password(v):

# the password should not be a
# newline or space
if v == "\n" or v == " ":
return "Password cannot be a newline or space!"

# the password length should be in
# between 9 and 20
if 9 <= len(v) <= 20:

# checks for occurrence of a character
# three or more times in a row
if re.search(r'(.)\1\1', v):
return "Weak Password: Same character repeats three or more times in a row"

# checks for occurrence of same string
# pattern( minimum of two character length)
# repeating
if re.search(r'(..)(.*?)\1', v):
return "Weak password: Same string pattern repetition"

else:
return "Strong Password!"

else:
return "Password length must be 9-20 characters!"

# Main method
def main():

# Driver code
print(password("Qggf!@ghf3"))
print(password("Gggksforgeeks"))
print(password("aaabnil1gu"))
print(password("Aasd!feasn"))
print(password("772*hd897"))
print(password(" "))


# Driver Code
if __name__ == '__main__':
main()