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 boolean
Flag indicating if lowercase letters should be included.private static boolean
Flag indicating if numbers should be included.private static boolean
Flag indicating if special characters should be included.private static boolean
Flag indicating if uppercase letters should be included.private static final String
Set of lowercase alphabetic characters (a-z).private static final String
Set of numeric characters (0-9).private static final String
Set of special characters.private static final String
Set of uppercase alphabetic characters (A-Z). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
buildCharSet
(StringBuilder charSet) Builds the final character set for password generation.private static boolean
checkValidity
(Scanner sc) Validates the user's input (Y/N) for character set inclusion.static void
The main entry point for the password generator application.private static void
promptUser
(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
- TheScanner
object 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
- TheStringBuilder
to store the combined character set.
-
checkValidity
Validates the user's input (Y/N) for character set inclusion.- Parameters:
sc
- TheScanner
object used for input.- Returns:
true
if the user selects 'Y', otherwisefalse
.
-