Encoding Passwords v1.0 In this assignment, you will review and implement loops, conditionals, and a one-dimensional arr
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Encoding Passwords v1.0 In this assignment, you will review and implement loops, conditionals, and a one-dimensional arr
Encoding Passwords v1.0 In this assignment, you will review and implement loops, conditionals, and a one-dimensional array. Traditional password entry schemes are susceptible to "shoulder surfing" in which an attacker watches an unsuspecting user enter their password or PIN number ans uses it later to gain access to the account. One way to combat this problem is with a randomized challenge-response system. In these systems, the user enters different information every time, based on a secret in response to a randomly generated challenge. Consider the following scheme in which the password consists of a five-digit PIN number (00000 to 99999). Each digit is assigned a random number that is 1, 2, or 3. The user enters the random numbers that correspond to their PIN instead of their actual PIN numbers. For example, consider an actual PIN number of 12345. To authenticate, the user would be presented with a screen such as: PIN: 0 1 2 3 4 5 6 7 8 9 CODE: 3 2 3 1 1 3 2 2 1 3 The user would enter 23113 instead of 12345. This doesn't divulge the password even if an attacker intercepts the entry because 23113 could correspond to other PIN numbers, such as 69440 or 70439. The next time the user logs in, a different sequence of random numbers would be generated, such as: PIN: 0 1 2 3 4 5 6 7 8 9 CODE: 1 1 2 3 1 2 2 3 3 3 Write a Java program to simulate the authentication process. Start by defining a class called Password. Password should contain instance data: • an array to hold the code as shown above . a max value which is the maximum value stored in the code array of type int Password should contain, at the minimum, the following methods: • Password (max) - a constructor which generates a set of random values to store in the code array. If max is 3, it will generate 10 random numbers between 1 and 3 stored in the code array. If max is 8, it will generate 10 random numbers between 1 and 8. etc. Each time the program is run, this code array should be different.
.toString() - returns a string representation of the object. Note that toString() methods do not print to the standard output stream, it simply returns a string version of the object with appropriate labels to identify the data. isCorrect (orig, entered) - returns true if the original PIN matches the entered password. In the earlier example, the call to isCorrect(12345, 23113) should return true, and so would isCorrect(69440, 23113) and isCorrect(70439, 23113). The main method should: 1. store an actual PIN number, 2. instantiate a Password object using a max value between 3 and 9, randomly generated, 3. present the user with random digits in the code array, 4. ask the user to input a response, 5. finally, output whether or not the user's response correctly matches the PIN number. Debug your code and be sure everything works before proceeding. Next, allow for multiple inputs. Allow the user to repeatedly enter actual and encoded passwords until the user choose to end the program. The sentinel-1 may be used to signify the program ending. For each set of original and encoded password, provide the code mapping (array) and report whether the encoded password is correct or not.
Sample Run: Enter the actual PIN: 54321 Actual PIN = 54321; max = 6 PIN: 0 1 2 3 4 5 6 7 8 9 Code: 3 6 5 4 6 4 6 1 1 4 Please enter your encoded PIN: 46456 YOU ARE RIGHT! Enter the actual PIN: 86420 Actual PIN = 86420; max = 5 PIN: 0 1 2 3 4 5 6 7 8 9 Code: 4 2 3 2 2 54523 Please enter your encoded PIN: 24234 YOU ARE RIGHT! Enter the actual PIN: 99887 Actual PIN = 99887; max = 7 PIN: 0 1 2 3 4 5 6 7 8 9 Code: 2 5 5 1 3 7 47 52 Please enter your encoded PIN: 25747 NOT CORRECT. SORRY!