Advertisement
_takumi

yes i am

Apr 14th, 2022
1,144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3.  
  4. #define BUF_SIZE 4095
  5.  
  6. unsigned int hash(const char * str) {
  7.     unsigned int arr[256];
  8.     unsigned int eax, b;
  9.     unsigned int i = 0;
  10.     unsigned int j = 0;
  11.     do {
  12.         eax = i;
  13.         b = 0;
  14.         do {
  15.             if ((eax & 1) != 0) {
  16.                 eax >>= 1;
  17.                 eax ^= -306674912;
  18.             } else {
  19.                 eax >>= 1;
  20.             }
  21.             b++;
  22.         } while (b != 8);
  23.         arr[i] = eax;
  24.         i++;
  25.     } while (i != 256);
  26.     eax = -1;
  27.     for (i |= str[j]; (i & 0x000000FF) != 0; i = str[j]) {
  28.         i ^= eax;
  29.         j++;
  30.         i &= 0x000000FF;
  31.         eax >>= 8;
  32.         eax ^= arr[i];
  33.     }
  34.     return ~eax;
  35. }
  36.  
  37. int main(void) {
  38.     char arr_s[BUF_SIZE];
  39.     fgets(arr_s, BUF_SIZE * sizeof(char), stdin);
  40.     printf("%x\n", hash(arr_s));
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement