@@ -163,7 +163,7 @@ else if(iv.length() != 32)
163163 if (aes .validline (line )) //If line is valid (i.e. contains valid hex characters, encrpyt. Otherwise, skip line.
164164 {
165165 if (line .length () < 32 ) {
166- line = String .format ("%" + 32 + "s" , line ). replace ( ' ' , '0' );
166+ line = String .format ("%032x" , Integer . parseInt ( line , 16 ) );
167167 }
168168 state = new int [4 ][4 ];
169169 for (int i = 0 ; i < 4 ; i ++) //Parses line into a matrix
@@ -243,7 +243,6 @@ else if (args[0].equalsIgnoreCase("d")) //Decryption Mode
243243 aes .addRoundKey (state , aes .subKey (keymatrix , 0 ));
244244 if (mode == Mode .CBC )
245245 {
246- System .out .println (MatrixToString (initvector ));
247246 aes .addRoundKey (state , initvector );
248247 aes .deepCopy2DArray (initvector ,nextvector );
249248 }
@@ -252,7 +251,6 @@ else if (args[0].equalsIgnoreCase("d")) //Decryption Mode
252251 }
253252 input .close ();
254253 out .close ();
255-
256254 }
257255 else
258256 {
@@ -261,11 +259,7 @@ else if (args[0].equalsIgnoreCase("d")) //Decryption Mode
261259 }
262260 }
263261
264- /**
265- * Checks the validity of the input line.
266- * @param line The line who's validity we check
267- * @return A boolean to determine validity
268- */
262+ //Helper method which executes a deep copy of a 2D array. (dest,src)
269263 private void deepCopy2DArray (int [][] copyTo , int [][] copyFrom )
270264 {
271265 assert copyTo .length == copyFrom .length && copyTo [0 ].length == copyFrom [0 ].length ;
@@ -274,7 +268,12 @@ private void deepCopy2DArray(int[][] copyTo, int[][] copyFrom)
274268 System .arraycopy (copyFrom [i ], 0 , copyTo [i ], 0 , copyTo [0 ].length );
275269 }
276270 }
277-
271+
272+ /**
273+ * Checks the validity of the input line.
274+ * @param line The line who's validity we check
275+ * @return A boolean to determine validity
276+ */
278277 private boolean validline (String line )
279278 {
280279 for (int i = 0 ; i < line .length (); i ++) {
0 commit comments