Question & Answer: IN JAVA: .Use and implement the RC4 cipher. The encryption program should work like a filter, readin…..

IN JAVA: .Use and implement the RC4 cipher. The encryption program should work like a filter, reading the contents of one file, modifying the data into code, and then writing the code contents out to a second file. The second file will be a version of the first file, but written in a secret code.

I am using Netbeans IDE so please give me something that works on Netbeans.and attach screenshot of ouput of working program with the answer thanks.

Don't use plagiarized sources. Get Your Custom Essay on
Question & Answer: IN JAVA: .Use and implement the RC4 cipher. The encryption program should work like a filter, readin…..
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS $13/PAGE
Order Essay

Expert Answer

 

Answer:
1. Create the input file with characters as input as mentioned in screen shot.
2. Create the output file with name mentioned in program.
3 . This logic will add 10 to each character.
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
public class EnFileExample {
private static final String FILENAME_IN = “E:\test\filenameIN.txt”;
private static final String FILENAME_OUT = “E:\test\filenameOUT.txt”;
public static void writeData(ArrayList list) {
BufferedWriter objBufferedWriter = null;
FileWriter objFileWriter = null;
try {
objFileWriter = new FileWriter(FILENAME_OUT);
objBufferedWriter = new BufferedWriter(objFileWriter);
String ff = list.toString().replace(“[“, “”);
objBufferedWriter.write(ff.replace(“]”, “”));
System.out.println(“Done”);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (objBufferedWriter != null)
objBufferedWriter.close();
if (objFileWriter != null)
objFileWriter.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
public static void main(String[] args) {
BufferedReader objBufferedReader = null;
FileReader objFileReader = null;
ArrayList list = new ArrayList();
try {
objFileReader = new FileReader(FILENAME_IN);
objBufferedReader = new BufferedReader(objFileReader);
String objSCurrentLine;
while ((objSCurrentLine = objBufferedReader.readLine()) != null) {
char objC = objSCurrentLine.charAt(0);
int objSc = (int) objC;
char c = (char) ((char)objSc + 10);
list.add(c);
}
writeData(list);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (objBufferedReader != null)
objBufferedReader.close();
if (objFileReader != null)
objFileReader.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
}

Output screenshot:

Input file:

Question & Answer: IN JAVA: .Use and implement the RC4 cipher. The encryption program should work like a filter, readin..... 1

Output file:

Question & Answer: IN JAVA: .Use and implement the RC4 cipher. The encryption program should work like a filter, readin..... 2

Still stressed from student homework?
Get quality assistance from academic writers!