You are not logged in.
Pages: 1
Hello, I would like to try using sha256 and possibly other hashes in BllomFilter, please see if I added the function correctly ?
TCrc32Algo = (
caCrc32c,
caCrc32,
caAdler32,
caxxHash32,
caFnv32,
caDefault,
caMd5,
caSha1,
caSha256);
function sha256c(crc: cardinal; buffer: pointer; len: cardinal): cardinal;
var
sha: TSha256;
dig: THash256Rec;
begin
sha.Init;
sha.Update(@crc, SizeOf(crc));
sha.Update(buffer, len);
sha.Final(dig.b);
result := dig.c[0] xor dig.c[1] xor dig.c[2] xor dig.c[3] xor dig.c[4];
end;
function CryptCrc32(algo: TCrc32Algo): THasher;
begin
case algo of
caCrc32c:
result := crc32c;
caCrc32:
result := crc32;
caAdler32:
result := adler32; // from mormot.lib.z - nil if unit was not included
caxxHash32:
result := @xxHash32;
caFnv32:
result := @fnv32;
caDefault:
result := DefaultHasher; // may use AES-NI with process-specific seed
caMd5:
result := @md5hash32;
caSha1:
result := @sha1hash32; // may use Intel SHA HW opcodes
caSha256:
result:= @sha256c;
else
result := nil;
end;
end;
Offline
You can indeed supply your own THasher function.
I have added caSha256 since it may be needed by someone else.
https://github.com/synopse/mORMot2/commit/bfda46d0
Offline
You can indeed supply your own THasher function.
I have added caSha256 since it may be needed by someone else.
https://github.com/synopse/mORMot2/commit/bfda46d0
Thank you very much
Offline
Pages: 1