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:
Write a program that asks for a password, then asks again to confirm it. If passwords don't match or the rules are not fulfilled, prompt again. Your program should include a method that checks whether a password is valid. Include javaDoc comments for all your methods.
Note: Could you plz go through this code and let me
know if u need any changes in this.Thank You
=================================
// PasswordValidator.java
import java.util.Scanner;
public class PasswordValidator {
public static void main(String[] args) {
//Declaring variable
String str = null;
// Scanner object is used to get the inputs entered by the
user
Scanner sc = new Scanner(System.in);
//This loop continue to execute until the user enters a valid
password
while(true)
{
System.out.print("\nEnter a new password :");
str = sc.nextLine();
if(isValidPassword(str))
{
System.out.println("Password is valid");
break;
}
}
}
private static boolean isValidPassword(String str) {
int count=0;
if(AtLeast10(str))
{
//Displaying the error message
System.out.println("Invalid: Too Few Characters (10 at
least)");
count++;
// continue;
}
if(!containsLowerCase(str))
{
System.out.println("Invalid:Contains at least 1 lower letter
character");
// continue;
count++;
}
if(!containsUpperCase(str))
{
System.out.println("Invalid:Contains at least 2 upper letter
character");
// continue;
count++;
}
/* checking whether the password contains letter or digit by
calling the method
* if yes,then this block of code get executed and display
* error message and prompt the user to enter again
*/
if (!containsDigit(str)) {
//Displaying the error message
System.out.println("Invalid: Contains at least 1 numeric
digit");
// continue;
count++;
}
if(count==0)
return true;
else
return false;
}
private static boolean containsDigit(String str) {
int count=0;
for(int i=0;i<str.length();i++)
{
if(Character.isDigit(str.charAt(i)))
{
count++;
}
}
if(count>=1)
return true;
else
return false;
}
private static boolean containsUpperCase(String str) {
int count=0;
for(int i=0;i<str.length();i++)
{
if(Character.isUpperCase(str.charAt(i)))
{
count++;
}
}
if(count>=2)
return true;
else
return false;
}
private static boolean containsLowerCase(String str) {
int count=0;
for(int i=0;i<str.length();i++)
{
if(Character.isLowerCase(str.charAt(i)))
{
count++;
}
}
if(count>=1)
return true;
else
return false;
}
/* This method will check whether the password length
* is atleast 8 or not
* Params : String
* Return : boolean
*/
private static boolean AtLeast10(String str) {
if(str.length()<8)
return true;
else
return false;
}
}
========================================
Output:
Enter a new password :Hello
Invalid: Too Few Characters (10 at least)
Invalid:Contains at least 2 upper letter character
Invalid: Contains at least 1 numeric digit
Enter a new password :hello
Invalid: Too Few Characters (10 at least)
Invalid:Contains at least 2 upper letter character
Invalid: Contains at least 1 numeric digit
Enter a new password :HEllo
Invalid: Too Few Characters (10 at least)
Invalid: Contains at least 1 numeric digit
Enter a new password :HELLOBOSS
Invalid:Contains at least 1 lower letter character
Invalid: Contains at least 1 numeric digit
Enter a new password :Helloboss
Invalid:Contains at least 2 upper letter character
Invalid: Contains at least 1 numeric digit
Enter a new password :HelloBoss
Invalid: Contains at least 1 numeric digit
Enter a new password :HelloBoss123
Password is valid
=====================Could you plz rate me well.Thank You
USING JAVA Having a secure password is a very important practice when much of our information...
Password Validation Write a program called PasswordValidationYourLastName that validates a new password, following these guidelines: Must be at least 8 characters Must have at least 1 uppercase letter Must have at least 1 lowercase letter Must have at least 1 digit 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...
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...
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...
FOR JAVA: Summary: Write a program to assess password stringency. The solution should be named Password.java. Include these steps: Write an application that provides the criteria for a strong password, and accepts a user's password from an input dialog box. If the entered password is less than six characters, more than 10 characters, or does not contain at least one uppercase letter and one digit, prompt the user to enter again. When the user's entry meets all the password requirements,...
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...
First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ==> Close All Projects). Then create a new Java application called "PasswordChecker" (without the quotation marks) that gets a String of a single word from the user at the command line and checks whether the String, called inputPassword, conforms to the following password policy. The password must: Be 3 characters in length Include at least one uppercase character Include at least...
Part 1: Is this Crazy Password Valid? A good password (in this strange system) should have the following properties: Rule 1: The password should be between 4 and 25 characters inclusive, starting with a letter. Rule 2. The password should not be contained in a list (selected by the user) that contains passwords commonly used by many people thus making these passwords easy to guess. Comparisons with passwords from the list of common passwords should be case insensitive. For example,...
How do I format this into C++? This the prompt: Design a class named Password that stores a password in a c-string and has member functions to test if the password complies with certain requirements as follows: The password should be between 6 and 20 characters long. The password should contain at least one uppercase and at least one lowercase letter. The password should have at least one digit. The password should have at least one punctuation character. Define a...
Create a simple Java class for a Password with the following requirements: This program will have a header block comment with your name, the course and section, as well as a brief description of what the class does. One String property: password (protected to only allow secure passwords) o A secure password must be at least 8 characters in length o A secure password must have three of the following four requirements: A lower case letter ...