/*linear feedback shift register of length L consisting of L stages numbered 0,1,......,L-1 each capable of storing one bit, the intial stage s0,s1,s2,.......,sL-1, stored in 0th,ist,2nd,.......,L-1th stage respecyively.0th stage is given the coeffnt. cl,1st stage the coeffnt. cL-1,..........L-1th stage the coeffnt. c1 */ #include #include #include #include #include #include const int a1=300; const int a2=300; void encrypt(); void lfsr(int[a1],int,int); void decrypt(void); void pass(int[a2]); int powr(int); void main() { //clrscr(); int chk; do { printf("\n--------------------------------------------------------------------------------\n"); printf("\n *MAIN MENU*"); printf("\n"); printf("\t \t \t \n *PR0GRAMME TO DEMONSTRATE LFSR*"); printf("\n--------------------------------------------------------------------------------\n"); printf("\n Press 1 to ENCRYPT:"); printf("\n Press 2 to DECRYPT:"); printf("\n Press 3 to EXIT:"); printf("\n Please enter your choice......"); scanf("%d",&chk); printf("\n"); switch(chk) { case 1: encrypt(); break; case 2: decrypt(); break; case 3: break; default: printf("\n You have enter a wrong choice!!!!!!!!\n"); break; } } while(chk!=3); } void encrypt() { char pln[40]; int l,L,s,cnt=0,cip[200],i; printf("\n Enter the length of the LFSR:"); scanf("%d",&L); printf("\n Enter the plain text:"); cin.getline(pln,'\40'); l=strlen(pln); printf("\n The plain text in binary form is:"); for(int k=0;k0); printf("%c",tmp); k=8; tmp=0; } } //end of decrypt function void lfsr(int cip[a1],int cnt,int L) { int s[400],i,c[10],j,ci[400]; printf("\n"); for(j=0;j<=cnt;j++) { s[j]=0; } printf("\n Enter the initial state:"); for(i=0;i0); printf("%c",tmp); k=8; tmp=0; } }//end of pass int powr(int k) { int l=1,i; for(i=1;i