34 lines
573 B
C
34 lines
573 B
C
//
|
|
// Created by haraldwolff on 06.08.22.
|
|
//
|
|
|
|
#include "../include/hash.h"
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
|
|
uint64_t dhash(void *data, int size){
|
|
uint64_t *i64 = (uint64_t*)data;
|
|
char *i8;
|
|
uint64_t hash = 0xbeefcafe;
|
|
|
|
while (size >= 8){
|
|
hash = rol64(hash, 23);
|
|
for (int n=0;n<16;n++) {
|
|
hash ^= *i64;
|
|
hash = ((hash>>32) * (hash>>32)) - ((hash & 0xffffffff) * (hash & 0xffffffff));
|
|
hash = rol64(hash, 16);
|
|
}
|
|
size -= 8;
|
|
i64++;
|
|
}
|
|
|
|
i8 = (char*)i64;
|
|
while (size > 0){
|
|
hash = ror64( hash, 11 );
|
|
hash ^= *(i8++);
|
|
size --;
|
|
}
|
|
|
|
return hash;
|
|
}
|