Package com.project
Class PassGenerator
java.lang.Object
com.project.PassGenerator
The
PassGenerator class generates random passwords based on user-selected criteria:
- Password length.
- Inclusion of numbers, uppercase, lowercase, and special characters.
The program uses a Random instance to select random characters from the chosen character sets.
It displays the generated password and allows the user to generate multiple passwords in a loop.
- Version:
- 1.0.0
- Author:
- Anurag Zete
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static booleanFlag indicating if lowercase letters should be included.private static booleanFlag indicating if numbers should be included.private static booleanFlag indicating if special characters should be included.private static booleanFlag indicating if uppercase letters should be included.private static final StringSet of lowercase alphabetic characters (a-z).private static final StringSet of numeric characters (0-9).private static final StringSet of special characters.private static final StringSet of uppercase alphabetic characters (A-Z). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidbuildCharSet(StringBuilder charSet) Builds the final character set for password generation.private static booleancheckValidity(Scanner sc) Validates the user's input (Y/N) for character set inclusion.static voidThe main entry point for the password generator application.private static voidpromptUser(Scanner sc) Prompts the user to select character sets for password generation.
-
Field Details
-
isNumbersIncluded
private static boolean isNumbersIncludedFlag indicating if numbers should be included. -
isUppercaseLettersIncluded
private static boolean isUppercaseLettersIncludedFlag indicating if uppercase letters should be included. -
isLowercaseLettersIncluded
private static boolean isLowercaseLettersIncludedFlag indicating if lowercase letters should be included. -
isSpecialCharactersIncluded
private static boolean isSpecialCharactersIncludedFlag indicating if special characters should be included. -
numbers
Set of numeric characters (0-9).- See Also:
-
lowercaseLetters
Set of lowercase alphabetic characters (a-z).- See Also:
-
uppercaseLetters
Set of uppercase alphabetic characters (A-Z).- See Also:
-
specialCharacters
Set of special characters.- See Also:
-
-
Constructor Details
-
PassGenerator
public PassGenerator()
-
-
Method Details
-
main
The main entry point for the password generator application.Displays a banner, prompts the user for password criteria, generates a password, and allows multiple password generations in a loop.
- Parameters:
args- The command-line arguments (not used).
-
promptUser
Prompts the user to select character sets for password generation.Asks whether to include:
- Numbers
- Uppercase letters
- Lowercase letters
- Special characters
- Parameters:
sc- TheScannerobject used for user input.
-
buildCharSet
Builds the final character set for password generation.Appends characters from the selected categories to the character set.
- Parameters:
charSet- TheStringBuilderto store the combined character set.
-
checkValidity
Validates the user's input (Y/N) for character set inclusion.- Parameters:
sc- TheScannerobject used for input.- Returns:
trueif the user selects 'Y', otherwisefalse.
-