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