Concept explainers
Using SIMPLE java, I need some help with file encryption. Looking for a way to read the first file one character at a time, and add some number between 1 and 31 to the ASCII character code of each character before it is written to the second file. The input file will contain printable characters from character 32 to character 125 in the ASCII character set. Thanks!
Here is code I have and I need help with the encrpytFile method.
public class Crypto
{
/**
The encryptFile method makes an encrypted copy
of an existing file.
@param existing The name of the existing file to encrypt.
@param encrypted The name of the encrypted file to create.
@exception IOException When an IO error occurs.
*/
private static final byte KEY = 10;
public static void encryptFile(String existing, String encrypted)
{
}
public class FileEncryptionFilter
{
public static void main(String[] args)
{
System.out.println("Encrypting the contents of the file");
System.out.println("MyLetters.txt. The encrypted file will");
System.out.println("be stored as Encrypted.txt");
try
{
Crypto.encryptFile("src//MyLetters.txt", "src//Encrypted.txt");
System.out.println("Done. Use Notepad to inspect the encrypted file.");
}
catch (IOException e)
{
System.out.println("Error - " + e.getMessage());
}
}
}
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 3 images
- how to Generate 4,000 random digits and save them in a text file (using ASCII coding), wherecharacters are separated by spaces and each line includes four characters. Repeat thepoker test by reading the numbers from the file in c programming languagearrow_forwardcan you do it pythonarrow_forwardI have a bit of code that is intended to read a file ("students.txt") and calculate the average, highest, and lowest scores from given information. (students.txt reads: " Mark Thompson 72.50James Taylor 100.00Daniel Price 80.2Busy Phillips 63.0 " ) This is the code I have: I have tweaked it to output the highest and lowest but I cannot get it to read the file. I have saved the file into the directory of the program but nothing seems to be working. I am also stumped on the formatting of the calculations. //////////////////////////////////////////// #include <iostream>#include <fstream>#include <cmath>#include <string>#include <iomanip>using namespace std; int main() { ifstream inFile; // This is a declaration of the inFile that holds all the gradesstring fileName; // This is the filename that the user will enterconst int min = 63.0; // This is a constant min used to find the lowest scoreconst int max = 100.0; // This is the constant max used to find the…arrow_forward
- IN PYTHON: Decrypting with ascii I have a file called 'dict.txt'. This file contains over 50,000 english words. One word from this file is used as a key (we do not know which one of course). Some have capital letters. I have another file called 'decrypt.txt' which is a file containing a string of numbers i must decrypt using a key found in the 'dict.txt'. This 'decrypt.txt' file message has length of 300. My question is, since i do not know which word (from the file with the 50,000+ words) is the key I must use to decrypt the other file, how do I write a function that: loops through all possible keys from 'dict.txt' to find the one that decrypts my file 'decrypt.txt' best? Somehow i must count how many 'words' are actual words to determine which key is best and then print my final decrypted message.arrow_forwardNeed help writing this java code, it has three objectives: to process strings to compare, search, sort, and verify location of specific pattern to output result via interface Description Write a Java program to read a text file (command line input for file name), process the text file and perform the following. Print the total number of words in the file. (When using java_test.txt, I calculate the number of words, including number, as 254.) Print the total number of different words (case sensitive, meaning “We” and “we” are two different words) in the file. (When using java_test.txt, I calculate the number of different words, including number, as 168.) Print all words in ascending order (based on the ASCII code) without duplication. Write a pattern match method to find the location(s) of a specific word. This method should return all line number(s) and location(s) of the word(s) found in the file. Print all line(s) with line number(s) where the word is found by invoking the method…arrow_forwardJava Your program must read a file called personin.txt. Each line of the file will be a person's name, the time they arrived at the professor's office, and the amount of time they want to meet with the professor. These entries will be sorted by the time the person arrived. Your program must then print out a schedule for the day, printing each person's arrival, and printing when each person goes in to meet with the professor. You need to print the events in order of the time they happen. In other words, your output will be sorted by the arrival times and the times the person goes into the professor's office. In your output you need to print out a schedule. In the schedule, new students go to the end of the line. Whenever the professor is free, the professor will either meet with the first person in line, or meet with the first person in line if nobody is waiting. Assume no two people arrive at the same time. You should solve this problem using a stack and a queue. You can only…arrow_forward
- here is a text file containing the details of several invoices details. Each invoice uses 3 lines of the file. The first of the three lines is a string giving the date of the invoice, for example “1/5/2021” or “2/6/2021”. The second of the three lines contains double giving the amount, the third line is boolean indicating whether it is paid or not. However, the very first line of the file is an integer number, which says how many invoices are given in the file in the lines which follow it (i.e. how many records will follow). Text file example for two vehicles “invoices.txt” 2 1/5/2021 50.0 true 2/6/2021 20.0 false Write code for a method named processTextFile() which will open the file named ‘invoices.txt’, from which it will read the data of invoices. It will create Invoice objects using this data by calling the constructor that takes the parameters (date, amount, paid) , placing them into an ArrayList invoiceList.arrow_forwardWrite a complete Python program that opens a file called sample.txt for reading, and opens a file called out.txt for writing.arrow_forwardCreate a program for caesar cipher in which the user enters a string of lowercase alphabets and the shift. The program should display the encoded string in the output. You can use the programming language of your choice but add the output screenshot in the file and test your code for the test case "fzyxtnavhal".arrow_forward
- Look at the image for the expected output. Use if class, scanner class, return class to do this program. Look image for the valid user input.arrow_forwardPython Please. and the data file is: 2121211143534722arrow_forwardI am trying to figure out why the sum at the end of my Java code is not working correctly. It keeps showing as zero and I do not know what the issue is. Here is the program requirements Write a program in a single file that: Main: Creates 10 random doubles, all between 1 and 11, Calls a method that writes 10 random doubles to a text file, one number per line. Calls a method that reads the text file and displays all the doubles and their sum accurate to two decimal places. SAMPLE OUTPUT 10.62691196041722.7377903389094555.4279257388651281.37420580654725091.18587002624988364.1803912764852284.9109699989306755.7108582343439587.7908570073730523.1806714736219543 The total is 47.13 Here is my code: import java.util.*;import java.io.*; public class AssignmentTwo { public static void main(String[] args) {//main method double randNum [] = new double [10]; for(int i = 0; i< randNum.length; i++) { randNum[i] = (double)(Math.random()* (10) + 1);…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education