Friday, July 31, 2020

Write a Program Key generation in Simplified DES in C.

Key generation in Simplified DES in C.


#include<stdio.h>
int main()
{
 int i, count=0, p8[8]={6,7,8,9,1,2,3,4};
 int p10[10]={6,7,8,9,10,1,2,3,4,5};
 
 char input[11], k1[10], k2[10], temp[11];
 char LS1[5], LS2[5];
 printf("Enter 10 Bits Input ::");
 scanf("%s",input); 
 input[10]='\0';

 for(i=0; i<10; i++)
 {
  count = p10[i];
  temp[i] = input[count-1];
 }
 temp[i]='\0';
 printf("\nYour p10 key is ::");
 for(i=0; i<10; i++)
 { printf("%d,",p10[i]); }
 
 printf("\nBits After p10 ::");
 puts(temp);
 for(i=0; i<5; i++)
 {
  if(i==4)
   temp[i]=temp[0];
  else
   temp[i]=temp[i+1];   
 }

 for(i=5; i<10; i++)
 {
  if(i==9)
   temp[i]=temp[5];
  else
   temp[i]=temp[i+1];   
 }
 printf("Output After LS-1 ::");
 puts(temp);
 
 printf("\nYour p8 Key is  ::");
 for(i=0; i<8; i++)
 { printf("%d,",p8[i]); }


 for(i=0; i<8; i++)
 {
  count = p8[i];
  k1[i] = temp[count-1];
 }
 printf("\nYour key k1 is :");
 puts(k1); 
}

OUTPUT

Enter 10 Bits Input :: Computer

Your p10 key is :: 6,7,8,9,10,1,2,3,4,5,

Bits After p10 :: ter
Output After LS-1 :: er

Your p8 Key is  :: 6,7,8,9,1,2,3,4,
Your key k1 is : ompuer

No comments:

Post a Comment

Please do not any spam link in Comment Box