-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1638 from AshutoshBuilds/master
Create Password_Strong_weak.py
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
Program's_Contributed_By_Contributors/Python_Programs/Password_Strong_weak.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |