DES2 - // Arup Guha // 11/7/06 // Solution for CIS 3362 DES...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: // Arup Guha // 11/7/06 // Solution for CIS 3362 DES Project // There are many weaknesses in this solution due to my laziness! // All of the constants in the algorithm should be stored in final // static variables, but I just wanted to read in the information // from the files instead of hard-coding them. // Also, the key should stay the same for encrypting one file, but // the blocks must change. This hasn't been indicated clearly. // Edited by Nickie McCall for 2010 Assignment import java.io.*; import java.util.*; public class DES { private int key; private int roundkeys; private int block; private static int stables; private static int IP; private static int IPInv; private static int E; private static int PC2; private static int P; private static int PC1; private static int keyshifts; // Reads all the information from the file I created based on the order // the values were stored in the file. My original posted file had some // errors in it, because some zeroes were stored as captial O's. I fixed // those issues in the file and have posted the corrected file with this // solution. public DES(int thekey) throws Exception { key = new int[64]; stables = new int[8][4][16]; IP = new int[64]; IPInv = new int[64]; E = new int[48]; PC2 = new int[48]; P = new int[32]; PC1 = new int[56]; keyshifts = new int[16]; block = new int[64]; // Sets the key to what was passed in. for (int i=0; i<64; i++) key[i] = thekey[i]; Scanner fin = new Scanner(new File("destables.txt")); // Reads in the initial permutation matrix. for (int i=0; i<64; i++) IP[i] = fin.nextInt(); // Reads in the inverse of the initial permutation matrix. for (int i=0; i<64; i++) IPInv[i] = fin.nextInt(); // Expansion matrix used in each round. for (int i=0; i<48; i++) E[i] = fin.nextInt(); // The permutation matrix P used in each round. for (int i=0; i<32; i++) P[i] = fin.nextInt(); // Reads in the 8 S-boxes! for (int i=0; i<8; i++) { for (int j=0; j<64; j++) { stables[i][j/16][j%16] = fin.nextInt(); } } // Reads in PC1, used for the key schedule. for (int i=0; i<56; i++) PC1[i] = fin.nextInt(); // Reads in PC2 used for the round keys. for (int i=0; i<48; i++) PC2[i] = fin.nextInt(); // Reads in the shifts used for the key between each round....
View Full Document

This note was uploaded on 07/13/2011 for the course CIS 3362 taught by Professor Staff during the Fall '08 term at University of Central Florida.

Page1 / 8

DES2 - // Arup Guha // 11/7/06 // Solution for CIS 3362 DES...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online