Password Validation
Write a program called PasswordValidationYourLastName that validates a new password, following these guidelines:
Write a program that asks for a password, and then asks again to confirm it (you can use the scanner or JOptionPane). Pass those two Strings to a method called validatePassword( ). Your validatePassword( ) should return a boolean - true if the passwords pass validation and false if the passwords do not pass validation.
If the passwords don’t meet validation rules, prompt again. If
the passwords meet validation rules, return “Password changed” and
exit the program.
Your validatePassword( ) method will check to see if the two
passwords passed in are valid. All of the checks should happen in
the method.
Right off the bat in your method, you should automatically return false if the passwords are not the same.
Again, if they are less than 8, then you can immediately return false too.
If the passwords are the same, then begin your checks listed above. You could use booleans variables as flags to keep track whether you've found an uppercase, lowercase and digit.
You can use isUpperCase(), isLowerCase(), isDigit() to check to see if something is a digit, uppercase or lowercase in the String.
After looking at the string, if all of your boolean variables are true (meaning you've found them), then you know your passwords are good.
Is there a reason to compare both passwords if they are the same? No. So just run your checks through one variable.
Again: use a boolean as your return type in the method. If any of the components are not met, change the boolean to false. Once the boolean is set to false, you know the password was not valid and you can return that to your main method as false for the re-prompting to happen again (probably in a loop of some kind).
Upload your .java file to Blackboard. This file is worth 15 points.
Java code
============================================================================================
package hello;
import java.util.Scanner;
public class PasswordValidationYourLastName {
static boolean validatePassword(String s1,String
s2)
{
boolean
isUpper=true,isLower=true,isNum=true;
String upperCaseChars =
"(.*[A-Z].*)";
String lowerCaseChars =
"(.*[a-z].*)";
String numbers =
"(.*[0-9].*)";
if(s1.equals(s2)==false)
{
System.out.println("Both password dont match.So try
again...");
return
false;
}
if(s1.length()<8)
{
System.out.println("Password Must be at least 8 characters in
length.");
return
false;
}
if (!s1.matches(upperCaseChars
))
{
System.out.println("Password should contain atleast one upper case
alphabet");
isUpper = false;
}
if (!s1.matches(lowerCaseChars
))
{
System.out.println("Password should contain atleast one lower case
alphabet");
isLower = false;
}
if (!s1.matches(numbers ))
{
System.out.println("Password should contain atleast one
number.");
isNum = false;
}
if(isUpper && isLower
&& isNum)
return
true;
else
return
false;
}
public static void main(String[] args) {
// TODO Auto-generated method
stub
Scanner sc=new
Scanner(System.in);
String s1,s2;
boolean b;
while(true)
{
System.out.print("Enter password: ");
s1=sc.next();
System.out.print("Confirm your password:");
s2=sc.next();
b=validatePassword(s1,s2);
if(b==true)
{
System.out.println("Password changed");
break;
}
}
}
}
============================================================================================
Output

Password Validation Write a program called PasswordValidationYourLastName that validates a new password, following these guidelines: Must...
USING JAVA Having a secure password is a very important practice when much of our information is stored online. Write a program that validates a new password, following these rules: The password must be at least 10 characters long. The password must have a least two uppercase and at least one lowercase letter The password must have at least one digit Write a program that asks for a password, then asks again to confirm it. If passwords don't match or...
Design a Java program to reset a user's password. The password must consist of exactly six characters, of which one must be a digit, one must be an uppercase letter, and one must be a lowercase letter. Tell the user if the password is correct or if incorrect tell them what is wrong with it. For example, you could say: "Not valid! the password must have 6 characters! Goodbye!" Can't contain loops. Using Boolean, String, Int, char
Write a program that asks the user to enter a password, and then checks it for a few different requirements before approving it as secure and repeating the final password to the user. The program must re-prompt the user until they provide a password that satisfies all of the conditions. It must also tell the user each of the conditions they failed, and how to fix it. If there is more than one thing wrong (e.g., no lowercase, and longer...
4: A certain computer program is accessed by entering a user-defined password. If the password a. can contain any lowercase letter, uppercase letter, or digit from 0-9, and must contain 10 characters, how many possible passwords are there if no character can be used more than once? Express your answer as a factorial statement. Is 8 an example of permutations or combinations? b.
4: A certain computer program is accessed by entering a user-defined password. If the password a. can...
Write a program that inputs a string from the user representing a password, and checks its validity. A valid password must contain: -At least 1 lowercase letter (between 'a' and 'z') and 1 uppercase letter (between 'A' and 'Z'). -At least 1 digit (between '0' and '9' and not between 0 and 9). At least 1 special character (hint: use an else to count all the characters that are not letters or digits). -A minimum length 6 characters. -No spaces...
Python Create a function that checks user input in an attempt to create a password. The valid_password function accepts a password as an argument and returns either true or false to indicate whether the password is valid. A valid password must be at least 7 characters in length, have at least one uppercase letter, one lowercase letter, and one digit. Respond with output to the user as to whether the password is valid or not, and allow the user to...
Create a program via Java that has atleast 8 characters long, one upper case, and one lower case, and one digit. here is my code: public static void main(String[] args) { //variables defined String passwords; char password =0; //settings up password condition to false boolean passwordcondition= false; boolean size=false; boolean digit=false; boolean upper=false; boolean lower=false; //inputting a scanner into the system Scanner keyboard = new Scanner(System.in);...
in C++, Design a program that asks the user to enter a password, and then analyze the password, and then analyze the password for the following weaknesses: 1. Fewer than 8 characters 2. Does not contain at least one uppercase letter and one lowercase latter 3. Does not contain at least one numeric digit 4. Does not contain at least one special character( a character that is not a letter or numeric digit) 5. Is a sequence of consecutive uppercase...
Please make this Python code execute properly. User needs to create a password with at least one digit, one uppercase, one lowercase, one symbol (see code), and the password has to be atleast 8 characters long. try1me is the example I used, but I couldn't get the program to execute properly. PLEASE INDENT PROPERLY. def policy(password): digit = 0 upper = 0 lower = 0 symbol = 0 length = 0 for i in range(0, len(password)): if password[i].isdigit(): # checks...