Password Generator
Password Generator
CSN203
Introduction to Java Programming
Submitted By
Name : Divyanshu Pranabh Singh
Roll no : 2301021190 230105092
SAP I’d : 1000021780 1000021839
Section : M M
Submitted to
Mr. Ravi Shankar Jha, Assistant Professor,
School of Computing
Introduction
3. StringBuilder:
- StringBuilder is used to construct the password dynamically.
- It allows efficient appending of characters without creating multiple string
objects.
4. Shuffling:
- The shuffleString method shuffles the characters of the password to ensure
randomness.
- This step uses ArrayList and Collections.shuffle to randomize the order of
characters.
The password will be generated by randomly selected the Symbols, Characters and Numbers
that are pre provided to the program.
Code and Output Screenshots
Java Code:
import java.util.*;
password.append(upperCase.charAt(random.nextInt(upperCase.length())));
password.append(lowerCase.charAt(random.nextInt(lowerCase.length())));
password.append(numbers.charAt(random.nextInt(numbers.length())));
password.append(symbols.charAt(random.nextInt(symbols.length())));
return shuffleString(password.toString());
}
This Java program effectively demonstrates how to generate a secure random password while
ensuring the inclusion of essential character types: at least one uppercase letter, one lowercase
letter, one digit, and one symbol. By leveraging the StringBuilder class for efficient string
manipulation, the Random class for randomness, and strategic character manipulation, the
program meets security criteria and user requirements.
Key Concepts:
- User Input Handling: Ensures the password length meets minimum security requirements.
- StringBuilder: Efficiently constructs the password without creating multiple string objects.
The program showcases the integration of multiple fundamental Java concepts and illustrates
how to build a robust utility for generating secure passwords. This approach can be applied to
other scenarios requiring secure random string generation.