import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; public class CbcVigenere { public static void main(String[] args) throws IOException { File f= new File(args[0]); BufferedReader bufferedReader = new BufferedReader(new FileReader(f)); StringBuffer stringBuffer = new StringBuffer(); String line; while((line =bufferedReader.readLine())!=null){ stringBuffer.append(line).append(\"\ \"); } String input = stringBuffer.toString(); String extract = input.replaceAll(\"[^a-zA-Z]+\", \"\").toLowerCase(); int k = extract.length(); String plaintxt = extract.replaceAll(\"(.{80})\",\"$1\ \"); System.out.println(\"Plaintext file name: \" + args[0]); System.out.println(\"Vigenere keyword: \" + args[1]); System.out.println(\"Initialization vector: \" + args[2]+ \"\ \"); System.out.println(\"Clean Plaintext:\ \ \" + plaintxt + \"\ \"); int pad=0; do { extract= extract + \"x\"; pad++; }while(extract.length() % args[1].length() != 0); int j=0; String fullcipher= \"\"; for( int i=0;i<(extract.length()/ args[1].length());i++){ String ciphertxt = encrypt(extract, args[1], args[2], j ); j=j + args[1].length(); args[2] = ciphertxt; fullcipher = fullcipher + ciphertxt; } //System.out.println(plaintxt.length()/args[1].length()); System.out.println(\"Ciphertext:\ \ \" + fullcipher.replaceAll(\"(.{80})\",\"$1\ \")); System.out.println(\"\ Number of characters in clean plaintext file: \" + k); System.out.println(\"Block size = \" + args[1].length()); System.out.println(\"Number is pad characters added: \" + pad); } public static String encrypt(String txt, String key, String IV, int pos){ String ab =\"\"; String cd =\"\"; for(int i=0; i Solution import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; public class CbcVigenere { public static void main(String[] args) throws IOException { File f= new File(args[0]); BufferedReader bufferedReader = new BufferedReader(new FileReader(f)); StringBuffer stringBuffer = new StringBuffer(); String line; while((line =bufferedReader.readLine())!=null){ stringBuffer.append(line).append(\"\ \"); } String input = stringBuffer.toString(); String extract = input.replaceAll(\"[^a-zA-Z]+\", \"\").toLowerCase(); int k = extract.length(); String plaintxt = extract.replaceAll(\"(.{80})\",\"$1\ \"); System.out.println(\"Plaintext file name: \" + args[0]); System.out.println(\"Vigenere keyword: \" + args[1]); System.out.println(\"Initialization vector: \" + args[2]+ \"\ \"); System.out.println(\"Clean Plaintext:\ \ \" + plaintxt + \"\ \"); int pad=0; do { extract= extract + \"x\"; pad++; }while(extract.length() % args[1].length() != 0); int j=0; String fullcipher= \"\"; for( int i=0;i<(extract.length()/ args[1].length());i++){ String ciphertxt = encrypt(extract, args[1], args[2], j ); j=j + args[1].length(); args[2] = ciphertxt; fullcipher = fullcipher + ciphertxt; } //System.out.println(plaintxt.length()/args[1].length()); System.out.println(.