Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The program should be made to accept hyphens (-) and spaces (whitespaces) and al

ID: 3632459 • Letter: T

Question

The program should be made to accept hyphens (-) and spaces (whitespaces) and also numbers. Any other characters should result in the program asking the user to input another number. The encryption code adder should be based on the area code 212. The uncrypted number shold always be 212. That is if the area code is 323, then the encryption shift is one (i.e. all numbers are shifted 1).

I understand that every code and program is difficult to write regardless of how simple it looks. I appreciate all your hard work. Thank you my friends.

Explanation / Answer

mport java.io.*; import java.security.*; import java.math.*; import cryptix.util.core.BI; import cryptix.util.core.ArrayUtil; import cryptix.util.core.Hex; import cryptix.provider.key.*; class test3des2_CBC { public static void main (String[] args) { try { FileOutputStream outFile1 = new FileOutputStream("DES-EDE3.out"); FileOutputStream outFile2 = new FileOutputStream("DES3CIPH.out"); //PrintStream is deprecated, but works fine in jdk1.1.7b PrintStream output1 = new PrintStream(outFile1); PrintStream output2 = new PrintStream(outFile2); //generate key for file encryption SecureRandom random = new SecureRandom(); KeyGenerator keygen = KeyGenerator.getInstance("DES-EDE3"); keygen.initialize(random); Key key = keygen.generateKey(); RawKey rkey = (RawKey) key; byte[] yval = rkey.getEncoded(); BigInteger Bkey = new BigInteger(yval); String w = cryptix.util.core.BI.dumpString(Bkey); output1.println("The Encryption Key = " + w); // create an Initialization Vector byte[] iv = new byte[8]; random.nextBytes(iv); Bkey = new BigInteger(iv); w = cryptix.util.core.BI.dumpString(Bkey); output1.println("The Initialization Vector = " + w); // define the encryption mode and initialize it Cipher des=Cipher.getInstance("DES-EDE3/CBC/PKCS#5","Cryptix"); des.initEncrypt(key); // read in the input file preceded by the Initialization Vector FileInputStream fis = new FileInputStream(args[0]); byte b; int bi; char bc; byte bb[] = new byte[1024]; int i; for(i=0;i