Friday, February 19, 2016

Simple Hash function implementation on 8 bits using XOR operation.

#include<stdio.h>
int main()
{
char ch, input[9], s[9];
int i, len=0;

printf("Enter your input bits:");
scanf("%s",input);

printf("Enter your key S (8 bits):");
scanf("%s",s);

printf("Your hash code is:");
for(i=0; i<8; i++)
{
ch=input[i]^s[i];
printf("%d",ch);
}
 return 0;
}

Output or program

Enter your input bits:11001100
Enter your key S (8 bits):01010101
Your hash code is:10011001

No comments:

Post a Comment