Pages

Wednesday, February 8, 2017

Simplified DES - Initial Permutation function

Simulation of Simplified DES - Initial Permutation function.
Note: Validations, Exceptions are to be added by programmer.


#include<stdio.h>
int main()
{
int IPkey[8]={1,6,7,8,5,2,3,4};
int i, cnt;
char input[9], output[9];

printf("Enter your 8 bits input:");
scanf("%s",input);
input[8]='\0';
printf("Your input is:%s\n", input);
printf("IP key used : ");
for(i=0; i<8; i++) {
printf("%d",IPkey[i]);
}
printf("\n");
for(i=0; i<8; i++)
{
cnt=IPkey[i];
output[i]=input[cnt-1];
}
output[8]='\0';

printf("Your output is %s", output);
return 0;
}

Output of the program

Enter your 8 bits input:10011101
Your input is:10011101
IP key used : 16785234
Your output is 11011001

No comments:

Post a Comment