Skip to content

Commit

Permalink
Merge pull request #1638 from AshutoshBuilds/master
Browse files Browse the repository at this point in the history
Create Password_Strong_weak.py
  • Loading branch information
fineanmol authored Oct 1, 2022
2 parents 5a548cb + 0e6973a commit 8c3d910
Showing 1 changed file with 47 additions and 0 deletions.
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()

0 comments on commit 8c3d910

Please sign in to comment.