/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package SS;
import javax.swing.JOptionPane;
/**
*
* @author David
*/
public class DES {
public static void main(String args[])
{
int i;
DesKey key;
key= new DesKey();
String s;
s=JOptionPane.showInputDialog(null,"Enter the number '0' for Default assumtion or '1' for if u want to enter the values for KEY");
//Do u want to enter the key or u want program to allot its own key ...If yes press YES or NO");
if(Integer.parseInt(s)==1)
{
key.enterkey();
}
else
{
key.getkey();
}
key.pc1();
key.subkeys();
key.putkey();
DesKey ptext;
ptext=new DesKey();
s=JOptionPane.showInputDialog(null,"Enter the number '0' for Default assumtion or '1' for if u want to enter the values for PLAIN TEXT");
//Do u want to enter the key or u want program to allot its own key ...If yes press YES or NO");
if(Integer.parseInt(s)==1)
{
ptext.entertext();
}
else
{
ptext.gettext();
}
System.out.println("\n\tAfter calcutating the Initial permutation of Encrypted message we get :\n");
ptext.ip();
for(i=1;i<17;i++)
{
ptext.Ebit();
ptext.xorwk(i,key);
ptext.sbox();
ptext.xorswap();
ptext.finl();
System.out.println("Here goes the round no : "+i+" using key no " +i);
}
ptext.swap();
System.out.println("\nThis is the enctrypted message : \n");
ptext.ipin();
System.out.println("\n\n\n\t\tNow Starts the decryption part\n");
System.out.println("\n\tAfter calculating the Initial permutation of Decrypted message we get :\n");
ptext.ip();
int r=1;
for(i=16;i>0;i--)
{
ptext.Ebit();
ptext.xorwk(i,key);
ptext.sbox();
ptext.xorswap();
ptext.finl();
System.out.println("\nHere goes the round no : "+r+" using key no " +i);
r++;
}
ptext.swap();
System.out.println("\nThis is the decrypted message\n");
ptext.ipin();
}
}