Miért .bin a kiterjesztése? UNIX-os binárisoknak nincs kiterjesztése. Írtam saját hash függvényt. Használjátok egész seggel:#ifndef _FHASH192_C
#define _FHASH192_C 1
#include <stdint.h>
#include <stdlib.h>
int fhash192(char *data, size_t length, uint32_t **hash_out)
{
size_t i;
char c, p, nc, np;
uint32_t j, mask, n, *hash;
if (hash_out == NULL)
{
hash = calloc(6, sizeof(uint32_t));
if (hash == NULL)
{
return 1;
}
}
else
{
hash = *hash_out;
}
mask = 0xe1b527ad;
p = 0;
for (i = 0; i < length; ++i)
{
np = ~p;
c = data[i];
nc = ~c;
n = c << 24 | c << 16 | c << 8 | c;
mask ^= ~n;
for (j = 0; j < 6; ++j)
{
hash[j] ^= mask;
hash[j] ^= n;
n = ~n;
mask = ((mask << 1) | (mask >> 31)) - 1;
}
n = (c ^ p);
n = n << 8 | n;
n = n << 16 | n;
n ^= mask;
hash[0] ^= n;
n = c << 24 | p << 16 | c << 8 | p;
hash[1] ^= n;
n = nc << 24 | np << 16 | nc << 8 | np;
hash[2] ^= n;
n = p << 24 | c << 16 | p << 8 | c;
hash[3] ^= n;
n = np << 24 | nc << 16 | np << 8 | nc;
hash[4] ^= n;
n = (nc ^ np);
n = n << 8 | n;
n = n << 16 | n;
n ^= ~mask;
hash[5] ^= n;
for (j = 0; j < 6; ++j)
{
n = hash[j];
hash[j] = hash[mask % 6];
hash[mask % 6] = n;
mask = ((mask >> 2) | (mask << 30)) + 2;
}
p = c;
}
*hash_out = hash;
return 0;
}
#endif Update 2018.07.18.: Beleraktam, hogy amennyiben a kimenet nem NULL, akkor nem allokál, hanem oda ír. np inicializálva, t eltávolítva (unused volt). |