0% found this document useful (0 votes)
9 views4 pages

Java Password Strength Evaluator

Uploaded by

Aditya 18--
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

Java Password Strength Evaluator

Uploaded by

Aditya 18--
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

Experiment 3
Student Name: RAJPAL PASWAN UID: 23BCS12424
Branch:BE CSE Section/Group: 818A
Semester: 4TH Date of Performance:10/3/25
Subject Name: JAVA Subject Code:23ITH202

1. Aim:

Write a Java program that prompts the user to enter a password. The

program should:

 Save the entered password to a file named "[Link]".

 Read the password from the file.

 Evaluate the password strength based on the following criteria:

o Weak: Length less than 4.

o Medium: Length between 4 and 7.

o Strong: Length 8 or more with a mix of letters and numbers.

o Very Strong: Length 8 or more with a mix of uppercase, lowercase,

numbers, and special characters.

 Save the strength evaluation to a file named "[Link]".

 Display the strength of the password in the console


DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

2. Java Code:

import [Link].*;

import [Link].*;

import [Link];

public class Main {

public static void main(String[] args) {

try (Scanner scanner = new Scanner([Link])) {

if (![Link]()) {

[Link]("No input provided.");

return;

String password = [Link]();

Path passwordPath = [Link]("[Link]");

[Link](passwordPath, password);

String storedPassword = [Link](passwordPath);

String strength = evaluateStrength(storedPassword);

Path evalPath = [Link]("[Link]");

[Link](evalPath, strength);
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

[Link](strength);

} catch (IOException e) {

[Link]("An error occurred.");

[Link]();

private static String evaluateStrength(String password) {

int length = [Link]();

boolean hasUpper = [Link](".*[A-Z].*");

boolean hasLower = [Link](".*[a-z].*");

boolean hasDigit = [Link](".*\\d.*");

boolean hasSpecial =

[Link](".*[!@#$%^&*(),.?\":{}|<>].*");

if (length >= 8 && hasUpper && hasLower && hasDigit &&

hasSpecial) return "Very Strong";

if (length >= 8 && (hasUpper || hasLower) && hasDigit) return

"Strong";
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

if (length >= 4) return "Medium";

return "Weak";

3. OUTPUT

You might also like