Java not 1 - if(i<32) l[i]=lr[i]; else...

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

View Full Document Right Arrow Icon
static int invp[64]={ 40, 8,48,16,56,24,64,32,39, 7,47,15,55,23,63,31, 38, 6,46,14,54,22,62,30,37, 5,45,13,53,21,61,29, 36, 4,44,12,52,20,60,28,35, 3,43,11,51,19,59,27, 34, 2,42,10,50,18,58,26,33, 1,41, 9,49,17,57,25}; void des_encrypt(unsigned char *input){ static unsigned char out[64]; static int inputb[64],lr[64],l[32],r[32]; static int fn[32]; static int cnt,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];
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if(i&lt;32) l[i]=lr[i]; else r[i-32]=lr[i]; } for(cnt=1;cnt&lt;=16;cnt++){ /*Main encryption loop*/ cypher(r,cnt,fn); for(i=0;i&lt;32;i++){ j=r[i]; r[i]=l[i]^fn[i]; l[i]=j; } } for(i=0;i&lt;32;i++){ lr[i]=r[i]; lr[i+32]=l[i]; } for(i=0;i&lt;64;i++) out[i]=lr[invp[i]-1]; /*Inverse IP*/ for(i=1;i&lt;=8;i++) for(j=1;j&lt;=8;j++) input[i-1]=(input[i-1]&lt;&lt;1)|out[i*8-j]; } void des_decrypt(unsigned char *input){ static unsigned char out[64]; static int inputb[64],lr[64],l[32],r[32]; static int fn[32];...
View Full Document

Ask a homework question - tutors are online