Skip to content

Instantly share code, notes, and snippets.

@vi
Created June 9, 2015 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vi/248db6d2d2bdc26d66cc to your computer and use it in GitHub Desktop.
Save vi/248db6d2d2bdc26d66cc to your computer and use it in GitHub Desktop.
#include <stdio.h>
void hash(const unsigned char* buf, size_t len, unsigned long long *hash1, unsigned long long *hash2)
{
unsigned long long &h=*hash1;
unsigned long long &j=*hash2;
size_t l = len;
const unsigned char* b = buf;
h=0xC0CC3051F486B191;
j=0x9A318B5A176B8125;
char q=0;
for(int i=0;i<l;++i){
char w=buf[i];
h+=((w<<27)*257);
j^=(h+0x5233);
h+=0xAA02129953CC12C3*(j>>32);
j^=(w+0x134)*(q-0x16C552F34);
q=w;
}
}
int main() {
unsigned char buf[1024];
int l = fread(buf, 1, 1024, stdin);
unsigned long long q, w;
hash(buf, l, &q, &w);
printf("%016llX%016llX\n", q, w);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment