Write a function in Java to generate a password and test whether
it meets specific
complexity criteria. Be creative with how you generate passwords -
strong passwords
have a mix of at least three of these attributes - lowercase
letters, uppercase letters,
numbers, and symbols. You can even prompt the user to ask them the
strength of
the password and adjust what is generated as an enhancement if you
like. The
passwords should be random, generating a new password every time
the user asks
for a new password. Passwords that you test for complexity strength
should also
meet the minimum criteria that you are using to generate them.
Code
import java.util.Scanner;
import java.security.SecureRandom;
public class Password
{
private static SecureRandom random = new SecureRandom();
/** different dictionaries used */
private static final String ALPHA_CAPS =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private static final String ALPHA =
"abcdefghijklmnopqrstuvwxyz";
private static final String NUMERIC = "0123456789";
private static final String SPECIAL_CHARS =
"!@#$%^&*_=+-/";
public static String generatePassword(int len)
{
String dic=ALPHA+ALPHA_CAPS+NUMERIC+SPECIAL_CHARS;
String result = "";
for (int i = 0; i < len; i++) {
int index = random.nextInt(dic.length());
result += dic.charAt(index);
}
return result;
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int strength;
System.out.print("Enter the strength of the password: ");
strength=sc.nextInt();
System.out.println("Your password is :
"+generatePassword(strength));
}
}
outputs



If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.
Write a function in Java to generate a password and test whether it meets specific complexity...
C++: Imagine you are developing a software package that requires users to enter their own passwords. Your software requires that users’ passwords meet the following criteria: -The password should be at least six characters long. You can set the maximum size and let the user know -The password should contain at least one uppercase and at least one lowercase letter. -The password should have at least one digit. Write a program that asks for a password into a c-string and...
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...
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...
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,...
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...
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...
In C Write a function that asks for the user's first, middle, and last names. The names will be entered by the user on a single line and will be stored in three different C-strings. The program should then store, in a fourth array, the name arranged in the following manner: the last name followed by a comma and a space, followed by the first name and a space, followed by the middle name. For example, if the user entered...
Hey all, if you could create a java program following these guidelines that would be much appreciated. helpful comments in the program would be appreciated :) The idea of this program is as followes : A password must meet special requirements, for instance , it has to be of specific length, contains at least 2 capital letters , 2 lowercase letters, 2 symbols and 2 digits. A customer is hiring you to create a class that can be utilized for...
In Java, I have created a program which can generate passwords. Currently the program can generate a password through a menu system of which characters to use. To complete the project, I need a system which allows the user to generate another password after the first password is created. I also need a method to check whether or not the password is complex by checking if the generated password has 3 or more character types and then displaying whether or...
JAVA PROBLEM! PLEASE DO IT ASAP!! REALLY URGENT! PLEASE DO NOT POST INCOMPLETE OR INCORRECT CODE Below is the program -- fill the code as per the instructions commented: //---------------------------------------------------------------------------------------------------------------------------------------------------------------// /* The idea of this HW is as follows : A password must meet special requirements, for instance , it has to be of specific length, contains at least 2 capital letters , 2 lowercase letters, 2 symbols and 2 digits. A customer is hiring you to create a class...