Password checker program basically checks if the password is valid or not based on password policies mention below:
- Password should not contain any space.
- Password should contain at least one digit(0-9).
- Password length should be between 8 to 15 characters.
- Password should contain at least one lowercase letter(a-z).
- Password should contain at least one uppercase letter(A-Z).
- Password should contain at least one special character ( @, #, %, &, !, $, etc….).
Input: GeeksForGeeks Output: Invalid Password! This input contains lowercase as well as uppercase letters but does not contain digits and special characters. Input: Geek$ForGeeks7 Output: Valid Password This input satisfies all password policies mentioned above.
In this program,
- we are using String contains () method to check the passwords. This method accepts a CharSequence as an argument and returns true if the argument is present in a string otherwise returns false.
- Firstly the length of the password has to be checked then whether it contains uppercase, lowercase, digits and special characters.
- If all of them are present then the method isValid(String password) returns true.
Below is the implementation of the above approach:
Invalid Password!!! Valid Password
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Program to check Strength of Password
- Strong Password Suggester Program
- How to validate a Password using Regular Expressions in Java
- Minimum characters required to make a password strong
- C Program to Check if a Given String is Palindrome
- Python program to check if a string is palindrome or not
- Program to check if input is an integer or a string
- Program to check for ISBN
- Program to check if a number belongs to a particular base or not
- Program to check for a Valid IMEI Number
- Program to check if all characters have even frequency
- Python program to check if a string contains all unique characters
- Python program to check if given string is vowel Palindrome
- Program to check if two strings are same or not
- Python program to check if given string is pangram
- Java program to check whether a string is a Palindrome
- Program to check if the String is Null in Java
- Program to check if the String is Empty in Java
- Program to check if a String in Java contains only whitespaces
- C++ program to check whether a String is a Pangram or not
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.