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