All pastes #395530 Raw Edit

Stuff

public java v1 · immutable
·published 2007-03-15 02:43 UTC
rendered paste body
import java.io.FileReader;import java.io.IOException;import java.io.PrintWriter;import java.util.Scanner;public class Driver{		public static void main(String[] args) {							// please put the input and key as capital letters!				Scanner input = new Scanner(System.in);				int done = 1;				do		{			System.out.println("Please enter 1 for encrypt or 2 for decrypt!");			int inputter = input.nextInt();			input.nextLine();			if (inputter == 1)			{				System.out.println("Please enter the filename:");				String filename = input.nextLine();				System.out.println("Please enter the encryption key:");				String key = input.nextLine();				String data = "";			// create data string				try				{					FileReader reader = new FileReader(filename);					Scanner in = new Scanner(reader);										while (in.hasNextLine())					{						data = data + in.nextLine();					}				}				catch (IOException exception)				{					System.out.println("Error processing file: " + exception);				}							Crypt encrypt = new Crypt(key);				String dataEncrypted = encrypt.encrypt(data);					PrintWriter out;				try {					out = new PrintWriter("encrypted.txt");					out.println(dataEncrypted);					out.close();					System.out.println("All done, check the output file!");				} 						catch (IOException exception)				{					System.out.println("Error processing file: " + exception);				}				System.out.println(dataEncrypted);												done = 0;			}									else if (inputter == 2)			{ //decrypt				System.out.println("Please enter the filename:");				String filename = input.nextLine();				System.out.println("Please enter the encryption key:");				String key = input.nextLine();				String datas = "";												try				{					FileReader reader = new FileReader(filename);					Scanner in = new Scanner(reader);					while (in.hasNextLine())					{						datas = datas + in.nextLine();					}				}				catch (IOException exception)				{					System.out.println("Error processing file: " + exception);				}							Crypt decrypt = new Crypt(key);				String dataDecrypted = decrypt.decrypt(datas);				PrintWriter out;				try {					out = new PrintWriter("decrypted.txt");					out.println(dataDecrypted);					out.close();					System.out.println("All done, check the output file!");				} 						catch (IOException exception)				{					System.out.println("Error processing file: " + exception);				}				System.out.println(dataDecrypted);				done = 0;			}					else							System.out.println("Invalid number, please try again!");							}while (done == 1);								}		}