Java not 2 - lr[i 32]=l[i for(i=0;i<64;i...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
static int cnt,rtemp,n; register int i,j; for(i=n=0;i<8;i++) for(j=0;j<8;j++) inputb[n++]=(input[i]>>j&0x01); for(i=0;i<64;i++){ /*Initial Permutation*/ lr[i]=inputb[p[i]-1]; if(i<32) l[i]=lr[i]; else r[i-32]=lr[i]; } for(cnt=16;cnt>0;cnt--){ /*Main decryption loop*/ cypher(r,cnt,fn); for(i=0;i<32;i++){ rtemp=r[i]; if(l[i]==1 && fn[i]==1) r[i]=0; else r[i]=(l[i] || fn[i]); l[i]=rtemp; } } for(i=0;i<32;i++){ lr[i]=r[i];
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: lr[i+32]=l[i]; } for(i=0;i<64;i++) out[i]=lr[invp[i]-1]; /*Inverse IP*/ for(i=1;i<=8;i++) for(j=1;j<=8;j++) input[i-1]=(input[i-1]<<1) | out[i*8-j]; } int main(int argc, char *argv){ unsigned char *key; unsigned char data[8]; int n; FILE *in; FILE *out; if (argc!=4) { printf("\r\nUsage: des [e][d] <source file> <destination file>\r\n"); return 1; } key=(unsigned char*)getpass("Enter Key:"); des_init(key);...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online