(Solved) : 18 File Encryption Science Writing Contents File Secret Code Encryption Program Work Like Q33096053 . . .
#18. File encryption is the science of writing the contents of afile in a secret code. Your encryption program should work like afilter, reading the contents of one file modifying the data into acode, and then writing the coded contents out to a second file.There are very complex encryption techniques, but for ours, willuse a simple one from the shift category. We will take eachcharacter and shift it one place in the Unicode sequence. So ‘a’becomes ‘b’, ‘b’ becomes ‘c’, etc. What about ‘z’? You could makeit ‘a’ or just the next Unicode character, which is the choice wewill take. NOTE: you must be writing and reading a text file, not aserializable one, and you must have a FileDialog ox where the usercan choose the file to utilize.
Write a program names EncryptDecrypt.java that has the followingmenu choices:
i. Read in a file
ii. Print the file to the console (obviously – this is fordebugging only)
iii. Encrypt the file and write it to the console
iv. Write out the encrypted file to a text file
v. Clear the data in memory
vi. Read in an encrypted file
vii. Decrypt the file
viii. Write out the decrypted file to the console
ix. End
I would like to use this stub methods to write the program:
public class EncryptDecrypt {
public static void main(String[] args) {
Scanner scan = newScanner(System.in);
ArrayList<String> file = newArrayList<String>();
int ans = 0;
while (true) {
menu();
System.out.println(“Make a selection:”);
ans =scan.nextInt();
if (ans == 1){
file = readText();
}
if (ans == 2){
printToConsole(file);
}
if (ans == 3){
file = encryptFile(file);
printToConsole(file);
}
if (ans == 4){
writeText(file);
}
if (ans == 5){
file.clear();
}
if (ans == 6){
file = readText();
}
if (ans == 7){
file = decryptFile(file);
}
if (ans == 8){
printToConsole(file);
}
if (ans == 9){
System.out.println(“See you later!”);
System.exit(0);
}
}
}
//menu item 1 and 6
public static ArrayList<String> readText(){
returnnull;
}
//menu item 4
public static void writeText(ArrayList<String>file) {
}
//menu items 2,3,8
public static voidprintToConsole(ArrayList<String> file) {
}
//menu item 3
public static ArrayList<String>encryptFile(ArrayList<String> file) {
return null;
}
//menu item 7
public static ArrayList<String>decryptFile(ArrayList<String> file) {
return null;
}
public static void menu() {
System.out.println(“n1. Read in afile”);
System.out.println(“2. Print thefile to the console”);
System.out.println(“3. Encrypt thefile and write it to the console”);
System.out.println(“4. Write outthe encrypted file to a text file”);
System.out.println(“5. Clear thedate in memory”);
System.out.println(“6. Read in anencrypted file”);
System.out.println(“7. Decrypt thefile”);
System.out.println(“8. Write outthe decrypted file to the console”);
System.out.println(“9.exitn”);
}
}
Expert Answer
Answer to 18 File Encryption Science Writing Contents File Secret Code Encryption Program Work Like Q33096053 . . .
OR