0% found this document useful (0 votes)
4 views12 pages

Java Password Generator Project Guide

The document outlines a Java project for generating passwords using character data types and ASCII values. It emphasizes the importance of using only learned commands and provides detailed steps for creating data files, formulating passwords, and generating output. The project requires the creation of various text files containing random integers representing different character types to be used in password generation.

Uploaded by

samlithika309
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)
4 views12 pages

Java Password Generator Project Guide

The document outlines a Java project for generating passwords using character data types and ASCII values. It emphasizes the importance of using only learned commands and provides detailed steps for creating data files, formulating passwords, and generating output. The project requires the creation of various text files containing random integers representing different character types to be used in password generation.

Uploaded by

samlithika309
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

As a reminder, we talked about only using commands we discussed and have used in class.

Commands
other than that are suspicious to me as I believe they are generated by AI. Even if you take the time to
learn about the commands after seeing it generated by AI, I do not want to see it used.

I am not alone in feeling this way. Across the country on the APCSA message boards, it is believed by
the majority that the use of Java commands outside of the scope of what was taught in class should is
suspicious.

Following all the directions asked, I need you to for the project must follow all directions cod
needs to using commands learned in APCSA

Java char and Password Generator Project

📘 Background
In Java, char is a primitive data type used to store a single 16‑bit Unicode

character. It is one of Java’s fundamental building blocks for handling


textual data.

Key Characteristics of char in Java


●​ Single Character Storage: A char variable can hold only one

character, such as 'A', 'b', '7', '$', or any other single Unicode

character.

●​ Unicode Representation: Java’s char type uses Unicode, which

means it can represent a wide range of characters from various


languages and symbols, not just the basic Latin alphabet.

●​ Numeric Interpretation: Although a char represents a character, it is

internally stored as a 16‑bit unsigned integer value corresponding to

its Unicode code point. This allows arithmetic operations on char

values (e.g., adding 1 to a char gives the next Unicode code point).

●​ Literal Representation: char literals are enclosed in single quotes, for

example:

None

char myChar = 'X';

👉 For this project, we will use a subset of Unicode called ASCII.


📝 Assignment Overview
You will create a series of data files containing integers related to different
characters. These integers will then be used to generate 8‑character
passwords using:
●​ Lowercase letters
●​ Uppercase letters
●​ Upper + Lowercase letters and numbers
●​ Upper + Lowercase letters, numbers, and symbols (ASCII ranges:
33–47, 58–64, 91–96, 123–126)

🔨 Step 1: Construct Data Files


Create a static method to generate the following files. All files must be
regenerated every time the program runs:

●​ [Link] → 160 random integers representing ASCII values for


lowercase letters
●​ [Link] → 160 random integers representing ASCII values for
uppercase letters - Codealong
●​ Mixed_letters_numbers.txt → 160 random integers representing
ASCII values for uppercase letters, lowercase letters, and numbers
●​ Mixed_chars.txt → 160 random integers representing ASCII values
for uppercase letters, lowercase letters, numbers, plus symbols in
ranges:
○​ 33–47
○​ 58–64
○​ 91–96
○​ 123–126 (This file includes every character on the ASCII
Reference Document except the space at character 32.)
🔑 Step 2: Formulate Passwords
Create a static method to generate 4 char arrays.

●​ Each array should contain 20 passwords, each 8 characters long.


●​ These arrays will be character representations of the integers read
from the data files above.

Example:

●​ Read [Link] and store each integer in the array as its

corresponding lowercase letter.

●​ Repeat for [Link], Mixed_letters_numbers.txt, and

Mixed_chars.txt.

💡 Reminder:
None

char upperA = (char)65; // 'A'

🖥️ Step 3: Generate Output


Print a menu and allow the user to select which set of passwords they want
to generate. Use a Switch statement to display the selected type of
passwords.

🎯 Sample Output
None

Welcome to the Password Generator!

Please select which type of Passwords you would

like to generate!

1. Lowercase letters

2. Uppercase letters

3. Uppercase, Lowercase, and Numbers

4. Uppercase, Lowercase, Numbers and Symbols

0. Exit

Enter Selection by typing numbers 1, 2, 3, 4 or 0

to Exit:

Do you wish to continue? (Give them a way to exit

or select another option)


Background: In Java, char is a primitive data type used to store a single
16-bit Unicode character. It is one of Java's fundamental building blocks for
handling textual data.

Here are the key characteristics of char in Java:

●​ Single Character Storage: A char variable can hold only one


character, such as 'A', 'b', '7', '$', or any other single Unicode
character.
●​ Unicode Representation: Java's char type uses Unicode, which
means it can represent a wide range of characters from various
languages and symbols, not just the basic Latin alphabet.
●​ Numeric Interpretation: Although a char represents a character, it is
internally stored as a 16-bit unsigned integer value corresponding to
its Unicode code point. This allows for arithmetic operations on char
values, where adding 1 to a char effectively gives the next Unicode
code point.
●​ Literal Representation: char literals are enclosed in single quotes, for
example, char myChar = 'X';.
●​ We will use a subset of Unicode called ASCII

In this assignment, you will create a series of data files containing integers
related to different characters. The integers will be used to create 8
character passwords using lowercase letters, uppercase letters, upper and
lower letters and numbers, and pper and lowercase letters, numbers, plus
characterss whose integer values range from 33-47, 58-64, 91-96, and
123-126.

Complete the project in the steps listed below:

Step 1: Construct Data Files


●​ Create a static method to generate the files below. All files need to be
generated everytime the program runs.

●​ “[Link]” - 1000 random int’s representing the ASCII


value for lowercase letters
●​ “[Link]” - 1000 random int’s representing the ASCII
value for uppercase letters
●​ “Mixed_letters_numbers.txt” - 1000 random int’s
representing the ASCII values for uppercase letters,
lowercase letters, and numbers
●​ “Mixed_chars.txt” - 160 random int’s representing the
ASCII values for upper and lowercase letters, numbers,
plus characterss whose integer values range from 33-47,
58-64, 91-96, and 123-126. (Basically this file includes
every character on the ASCII Reference Document except
the space found at character 32.)

Step 2: Formulate Passwords

●​ Create a static method to generate 5 char arrays. Each array


should contain 20 passwords that are 8 characters long. These
arrays will be character representations of the integers read
from the Data Files above.
●​ For example: Read “[Link]” and store each integer the
array as its corresponding lowercase letters
■​ Note: char upperA=(char)65;
●​ Repeat for [Link], Mixed_letters_numbers.txt, and
Mixed_chars.txt
Step 3: Generate Output
●​ Print a Menu and have the user select what set of passwords
they want to generate.
●​ Use a Switch Statement to display the selected type of
passwords.

Sample Output:
Welcome to the Password Generator!
Please select which type of Passwords you would like to generate!

[Link] letters
[Link] letters
[Link], Lowercase, and Numbers
[Link], Lowercase, Numbers and Symbols
[Link]

Enter Selection by typing numbers 1,2,3,4 or 0 to Exit:


Do you wish to continue? (Give them a way to exit or select another option)

import [Link].*;
import [Link].*;

public class MyProgram


{
public static void main(String[] args) throws IOException
{
generateFiles();
char[][] lowerPasswords = buildPasswords("[Link]");
char[][] upperPasswords = buildPasswords("[Link]");
char[][] mixedLNPasswords = buildPasswords("Mixed_letters_numbers.txt");
char[][] mixedAllPasswords = buildPasswords("Mixed_chars.txt");

Scanner input = new Scanner([Link]);


int choice;

do
{
[Link]("\nWelcome to the Password Generator!");
[Link]("Please select which type of Passwords you would like to
generate!\n");
[Link]("1. Lowercase letters");
[Link]("2. Uppercase letters");
[Link]("3. Uppercase, Lowercase, and Numbers");
[Link]("4. Uppercase, Lowercase, Numbers and Symbols");
[Link]("0. Exit");
[Link]("\nEnter Selection: ");

choice = [Link]();

switch (choice)
{
case 1:
printPasswords(lowerPasswords);
break;
case 2:
printPasswords(upperPasswords);
break;
case 3:
printPasswords(mixedLNPasswords);
break;
case 4:
printPasswords(mixedAllPasswords);
break;
case 0:
[Link]("Goodbye!");
break;
default:
[Link]("Invalid choice.");
}
} while (choice != 0);
}

//file
public static void generateFiles() throws IOException
{
Random rand = new Random();

// lowercase (1000)
writeRandomInts("[Link]", 1000, rand, new int[][]{{97, 122}});

// uppercase (1000)
writeRandomInts("[Link]", 1000, rand, new int[][]{{65, 90}});

// upper + lower + num (1000)


writeRandomInts("Mixed_letters_numbers.txt", 1000, rand,
new int[][]{{65, 90}, {97, 122}, {48, 57}});

// all 160
writeRandomInts("Mixed_chars.txt", 160, rand,
new int[][]{
{33, 47},
{48, 57},
{58, 64},
{65, 90},
{91, 96},
{97, 122},
{123, 126}
});
}

private static void writeRandomInts(String fileName, int count, Random rand, int[][] ranges)
throws IOException
{
PrintWriter out = new PrintWriter(new FileWriter(fileName));

for (int i = 0; i < count; i++)


{
int[] range = ranges[[Link]([Link])];
int value = [Link](range[1] - range[0] + 1) + range[0];
[Link](value);
}
[Link]();
}
//passwords
public static char[][] buildPasswords(String fileName) throws IOException
{
char[][] passwords = new char[20][8];
Scanner file = new Scanner(new File(fileName));

for (int i = 0; i < 20; i++)


{
for (int j = 0; j < 8; j++)
{
int ascii = [Link]();
passwords[i][j] = (char) ascii;
}
}
[Link]();
return passwords;
}

// output
public static void printPasswords(char[][] passwords)
{
[Link]("\nGenerated Passwords:\n");
for (int i = 0; i < [Link]; i++)
{
for (int j = 0; j < passwords[i].length; j++)
{
[Link](passwords[i][j]);
}
[Link]();
}
}
}

You might also like