Question: Implement in Java a semi One-Time pad algorithm that the entire process should be done in one file. The key should be randomly generated. No

Implement in Java a semi One-Time pad algorithm that the entire process should be done in one file. The key should be randomly generated. No need to keep track of the keys you generated previously. However, the key should not be predictable. The key should be converted into binary and stored in a file.

For the encryption function, you need to accept a plaintext message from a file. Then convert it into binary. After that, you must read the key from a file as well. Afterwards, you can easily encrypt the plaintext with the key to obtain the ciphertext. Assume that the plaintext will always be string. Once you obtain the ciphertext, write it into a file in its binary representation.

For the decryption function, read a file that has the ciphertext and the file that has the key. Finally, decrypt the result and simply print the result.

a one time pad is ONLY considered secure if the key is AS LONG as the plaintext.

Also, remember that a character is 8 bits (or 1 byte)

The key must be RANDOMLY generated and must be generated in a secure way.

To make your program easier:

I will accept 2 programs:

1- key generation

2- encryption OR decryption depending on the user choice

The first program should only generate a random key and store it in a file.

The second program should give the user an option to either encrypt OR decrypt.

If the user choses to encrypt, the program will take the key file and the plaintext file (in ASCII) and output a file with the ciphertext version (in binary)

If the user choses to decrypt, the program will take the key file and the ciphertext file and output a file with the plaintxt version (in ASCII).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!