Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose an encrypted file was created by adding 3 to every value in the file. create a program to decode the encrypted file. Your program

Suppose an encrypted file was created by adding 3 to every value in the file. create a program to decode the encrypted file. Your program should prompt the user to enter an input file name and an output file name .

Run the following program to create the encrypted file. Please use the file temp.dat as input. The file temp.dat is attached to this assignment. Name the output file tempEncryptedf22.dat.

import java.util.Scanner;

import java.io.*;

public class EncryptFile {

public static void main(String[] args) throws Exception {

Scanner input = new Scanner(System.in);

System.out.print("Enter a file to encrypt: ");

BufferedInputStream in = new BufferedInputStream(

new FileInputStream(new File(input.next())));

System.out.print("Enter the output file: ");

BufferedOutputStream output = new BufferedOutputStream(

new FileOutputStream(new File(input.next())));

int value;

while ((value = in.read()) != -1) {

output.write(value + 3);

}

input.close();

output.close();

}}

create a program to decrypt the file tempEncryptedf22.dat. Print each decrypted value as you read and decrypt. Write out the decrypted file to a new file. Name the decrypted file tempDecrypted.dat. Name your program HW6.java.

image text in transcribed

C. Command Prompt G:\OneDrive\Shared favorites\class Work is 247 wk7_binary 10_ch17\hw>java HW7Solution Enter an encrypted file: tempEncrypted.dat Enter the output file: tempDecrypted.dat wrote decrypted value to the decrypted fil wrote decrypted value 2 to the decrypted file wrote decrypted value 4 to the decrypted file wrote decrypted value 6 to the decrypted file wrote decrypted value 8 to the decrypted file wrote decrypted value 10 to the decrypted file wrote decrypted value 12 to the decrypted file wrote decrypted value 14 to the decrypted file wrote decrypted value 16 to the decrypted file wrote decrypted value 18 to the decrypted file wrote decrypted value 20 to the decrypted file wrote decrypted value 22 to the decrypted file wrote decrypted value 24 to the decrypted file wrote decrypted value 26 to the decrypted file wrote decrypted value 28 to the decrypted file G:\OneDrive\Shared favorites\class Work\is 247 wk7_binary 10_ch17\hw>

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

Step: 3

blur-text-image

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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

Factor completely. 3(r + 5) - 11(r + 5) 4

Answered: 1 week ago

Question

=+Describe the features of costvolumeprofit (CVP) analysis

Answered: 1 week ago