From 54eacb1643650d1598c222e71b9243ddb688e72e Mon Sep 17 00:00:00 2001 From: Siri Lalitha Date: Tue, 24 Oct 2023 15:00:40 +0530 Subject: [PATCH 1/2] create strong_password_detection.py --- strong_password_detection.py | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 strong_password_detection.py diff --git a/strong_password_detection.py b/strong_password_detection.py new file mode 100644 index 000000000000..cf1c941e09b2 --- /dev/null +++ b/strong_password_detection.py @@ -0,0 +1,43 @@ +def strong_password_detection(password): + + AllowedSymbols = ['#', '@', '$', '_', '*', '-'] + flag = 1 + # length of the entered password should be at least 6 + if len(password) < 6: + print('length of the entered password should be at least 6') + flag = 0 + # length of the entered password should be not be greater than 15 + if len(password) > 15: + print('length of the entered password should be not be greater than 15') + flag = 0 + # The entered password should have at least one numeral + if not any(char.isdigit() for char in password): + print('The entered password should have at least one numeral') + flag = 0 + # Password should have at least one lowercase letter + if not any(char.islower() for char in password): + print('the entered password should have at least one lowercase letter') + flag = 0 + # The entered password should have at least one uppercase letter + if not any(char.isupper() for char in password): + print('The entered password should have at least one uppercase letter') + flag = 0 + # The entered password should have at least one of the symbols $@#_* + if not any(char in AllowedSymbols for char in password): + print('The entered password should have at least one of the symbols $@#_*') + flag = 0 + if flag: + return flag + + +def main(): + password = input() + + if (strong_password_detection(password)): + print("The entered password is strong !!") + else: + print("The entered password is weak !!") + + +if __name__ == '__main__': + main() From 915827dd5fc7185957c11b149998d6017c81dbe3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 24 Oct 2023 09:33:25 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- strong_password_detection.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/strong_password_detection.py b/strong_password_detection.py index cf1c941e09b2..91926dbbb02f 100644 --- a/strong_password_detection.py +++ b/strong_password_detection.py @@ -1,30 +1,29 @@ def strong_password_detection(password): - - AllowedSymbols = ['#', '@', '$', '_', '*', '-'] + AllowedSymbols = ["#", "@", "$", "_", "*", "-"] flag = 1 # length of the entered password should be at least 6 if len(password) < 6: - print('length of the entered password should be at least 6') + print("length of the entered password should be at least 6") flag = 0 # length of the entered password should be not be greater than 15 if len(password) > 15: - print('length of the entered password should be not be greater than 15') + print("length of the entered password should be not be greater than 15") flag = 0 # The entered password should have at least one numeral if not any(char.isdigit() for char in password): - print('The entered password should have at least one numeral') + print("The entered password should have at least one numeral") flag = 0 # Password should have at least one lowercase letter if not any(char.islower() for char in password): - print('the entered password should have at least one lowercase letter') + print("the entered password should have at least one lowercase letter") flag = 0 # The entered password should have at least one uppercase letter if not any(char.isupper() for char in password): - print('The entered password should have at least one uppercase letter') + print("The entered password should have at least one uppercase letter") flag = 0 # The entered password should have at least one of the symbols $@#_* if not any(char in AllowedSymbols for char in password): - print('The entered password should have at least one of the symbols $@#_*') + print("The entered password should have at least one of the symbols $@#_*") flag = 0 if flag: return flag @@ -33,11 +32,11 @@ def strong_password_detection(password): def main(): password = input() - if (strong_password_detection(password)): + if strong_password_detection(password): print("The entered password is strong !!") else: print("The entered password is weak !!") -if __name__ == '__main__': +if __name__ == "__main__": main()