How to Create Password Validator in Python

How to Create Password Validator in Python

Introduction

In this tutorial we will create a How to Create Password Validator in Python. This tutorial purpose is to secure your login process with a strict password validator. This will cover all the important parts for creating the password validator. I will provide a sample program to show the actual coding of this tutorial.

This tutorial will make it easy for you to understand just follow my instruction I provided and you can do it without a problem. This program is useful if you have a login system, this will ensure heighten your security measure for creating a password. I will try my best to give you the easiest way of creating this program How to Create Password Validator in Python. So let's do the coding.

Getting Started:

First you will have to download & install the Python IDLE's, here's the link for the Integrated Development And Learning Environment for Python https://www.python.org/downloads/.

Creating Main Function

This is the main function of the application is. This code will provide a strict method for creating your password. To do this just copy and write these block of codes inside the IDLE text editor.
  1. def password_check(passwd):
  2.  
  3. SpecialSym =['$', '@', '#', '%']
  4. val = True
  5.  
  6. if len(passwd) < 6:
  7. print('length should be at least 6')
  8. val = False
  9.  
  10. if len(passwd) > 20:
  11. print('Length should be not be greater than 8')
  12. val = False
  13.  
  14. if not any(char.isdigit() for char in passwd):
  15. print('Password should have at least one numeral')
  16. val = False
  17.  
  18. if not any(char.isupper() for char in passwd):
  19. print('Password should have at least one uppercase letter')
  20. val = False
  21.  
  22. if not any(char.islower() for char in passwd):
  23. print('Password should have at least one lowercase letter')
  24. val = False
  25.  
  26. if not any(char in SpecialSym for char in passwd):
  27. print('Password should have at least one of the symbols [email protected]#')
  28. val = False
  29. if val:
  30. return val
  31.  
  32.  
  33. def main():
  34. print("\n\n############### Password Validator ###############\n\n")
  35. a=True
  36. while a:
  37. passwd = input("Enter your Password: ");
  38.  
  39. if (password_check(passwd)):
  40. print("Password is valid")
  41. a=False
  42. else:
  43. print("Invalid Password !!")

In the given code we first create a method that will validate the password. We put some several functionality to ensure security of the password you have created. After that we apply the created method a loop to check if the password is strong or not.

Initializing the Application

After finishing the function save the application as index.py. This function will run the code and check if the main is initialize properly. To do that copy and write these block code after the main function inside the IDLE text editor.

  1. if __name__ == '__main__':
  2. main()

Output:

The How to Create Password Validator in Python source code that I provide can be download below. Please kindly click the download button.

There you have it we successfully created How to Create Password Validator in Python. I hope that this simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!

More Tutorials for Python Language

Python Tutorials

Add new comment