Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write the below program using java. Write a program that reads from the keyboard a small password and then offers two options: 1. enter your

Write the below program using java.

Write a program that reads from the keyboard a small password and then offers two options: 1. enter your name and a filename to save or 2. enter a file name to load.

With the option 1 proceed to save to the file an encrypted version of your name (details below), with the option 2 proceed to load the information from the file and decrypt the name and print it to the screen.

The options 1 and 2 are in reverse (1 saves the encrypted information to the file, 2 decrypts the information from the file).

Details of the encryption:

Say your name is Andrei and you chose the password 1234, then you do XOR between the ASCII code for A (first letter in your name) and the ASCII code for 1(first letter in your password), I will denote this operation (A,1)

then you do XOR between n and 2 (n,2) (second letter in your name with second letter in password) and so on, thus we will have the following operations to perform:

(A,1) (n,2) (d,3) (r,4) (e,1) (i,2).

Obviously, if you would choose the password qwer then the XOR operations will be between the following pairs:

(A,q)(n,w)(d,e)(r,r)(e,q)(i,w).

The trick is that the encrypted text can be decrypted due to the following property of XOR: A XOR B=C; C XOR B=A, thus if I have the results of the XOR operations in the file (and this is your name encrypted) then it is sufficient to do XOR with the same password (with the same ASCII codes) and I will get back the original string.

For example, with the first password, (A XOR 1) XOR 1 =A, (n XOR 2) XOR 2=n and so on:

((A,1),1) ((n,2),2) ((d,3),3) ((r,4),4) ((e,1),1) ((i,2),2)= A n d r e i.

BONUS for 2p, please specify clearly if you submit the bonus or not, either with 3 java files each one for part a, part b and part c or in comments in the first couple of lines in the code:

Make the reading of the password from the keyboard not visible (each time you type a letter you print on the screen a * or not print anything) and give the option to the user to "show password" in case there is a typo.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions

Question

2. Provide recommendations for effective on-the-job training.

Answered: 1 week ago

Question

Complexity of linear search is O ( n ) . Your answer: True False

Answered: 1 week ago

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago