Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #define BUF_SIZE 4095
- int hash(char * s) {
- int arr[256];
- int a, b, i = 0, j = 0;
- do {
- a = i;
- b = 0;
- do {
- if ((a & 1) != 0) {
- a >>= 1;
- a &= 0x7FFFFFFF;
- a ^= -306674912;
- } else {
- a >>= 1;
- a &= 0x7FFFFFFF;
- }
- b++;
- } while (b != 8);
- arr[i] = a;
- i++;
- } while (i != 256);
- a = -1;
- // --
- i |= s[j];
- while ((i & 0x000000FF) != 0) {
- i ^= a;
- j++;
- i &= 0x000000FF;
- a >>= 8;
- a &= 0x00FFFFFF;
- a ^= arr[i];
- i = s[j];
- }
- // --
- a = ~a;
- return a;
- }
- int main(void) {
- char s[BUF_SIZE];
- fgets(s, sizeof(char) * BUF_SIZE, stdin);
- printf("%x\n", hash(s));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement