Question: Java : File encryption is the science of writing the contents of a file in a secret code. Your encryption program should work like a

Java :  Java : File encryption is the science of writing the contents

File encryption is the science of writing the contents of a file in a secret code. Your encryption program should work like a filter, reading the contents of one file, modifying the data into a code, and then writing the coded contents out to a second file. The second file will be a version of the first file, but written in secret code. Use text (ASCII) files for this exercise. Create another program to read and decrypt the contents of the coded file, restore the data to its original state, and display the original data to the user. Although there are complex encryption techniques, you should come up with a simple one of your own. For example, you could read the first file one character at a time, and add 10 to the character code of each character before it is written to the second file. This is called a shift-cypher. Your cipher code should make sure that it encodes the data into valid characters and the decryption code should expect to decipher valid characters back into the original data. Please refer to Appendix 3 of your text to see the int values for the valid ASCII printable characters. The biggest int value in ASCII is 255 and the smallest is 0. You will need to take this into consideration when deciding on your encryption technique. For example, multiplying n * 3 would result in an invalid character as the ASCII code for n is 110. This would give you 330 which is out-of-bounds for the 8 bit character. To make sure your values never exceed the max of 255 or the min of 0, you may find the mod operator is helpful

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!