Your final project assignment is a simple encrypted file system. You may choose
ID: 3732757 • Letter: Y
Question
Your final project assignment is a simple encrypted file system. You may choose to either implement it in the kernel, or as a user-level application.
There are several simplifying assumptions that you are free to make:
You need only support a single level of names. In other words, you don't have to support any subdirectories in your file server.
You can ignore the remove and wstat operations.
Your server need not authenticate clients.
Start by implementing a basic file system that can handle the create, open, read, write, and stat operations. Then add some form of encryption. You'll need to support a synthetic control file to which the key is written. As a basic version, keep the contents of the files in memory. For a more challenging version, store the encrypted files in persistent storage. I.e. Make your file system implementation exist as a layer on top of an existing file system.
As usual, you should turn in any code you modify or write and documentation for your design and testing.
Explanation / Answer
Below is the Running Java Code for simple Encryption and Decryption of String without using any standard algorithm.
I used the encrypted File handling,String will store in the system drive in encrypted format and when i want to read it will first decrypt and after that will show as output to the user(Original form).
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package cheggquestions;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
/**
*
* @author Prashant Tomer
*/
public class Encryption {
String plainText="Chegg"; //Input String
public void readFile(String filepath) //Way to read the file content
{
try
{
FileReader fr=new FileReader(filepath);
BufferedReader br=new BufferedReader(fr);
String dec=null;
while((dec=br.readLine())!=null)
{
System.out.println(dec);
String str1=decrypt(dec);
System.out.println(str1);
}
}catch(Exception ex)
{
System.out.println(ex);
}
}
public void WriteFile(String filepath) //Method to write cntent into file
{
try
{
FileWriter fw=new FileWriter(filepath);
BufferedWriter bfw=new BufferedWriter(fw);
String str1=encrypt(plainText); //call the encrypt
bfw.write(str1);
bfw.close();
}catch(IOException ex)
{
System.out.println("Exception in your program");
}
}
private static String encrypt(String plainText) //Encrypt the string
{
String str="";
for (int i = 0; i < plainText.length(); i++) {
char ch=(char) (plainText.charAt(i)+(char)10);
str=str+ch;
}
return str;
}
private static String decrypt(String decryptedText) //decrypt the string
{
String str="";
for (int i = 0; i < decryptedText.length(); i++)
{
char ch=(char) (decryptedText.charAt(i)-(char)10);
str=str+ch;
}
return str;
}
public static void main(String aa[])
{
System.out.println(plainText);
Encryption obj=new Encryption();
String filepath="D:\playlist.txt";
obj.WriteFile(filepath);
obj.readFile(filepath);
}
}
O/P:
Chegg
Mroqq
Chegg
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.