A fast mostly collision free hash ?
Thibaut Cuvelier
dourouc05 at gmail.com
Tue Nov 8 22:06:49 UTC 2022
On Tue, 8 Nov 2022 at 20:45, Pavel Sanda <sanda at lyx.org> wrote:
> On Tue, Nov 08, 2022 at 04:43:15PM +0100, Jean-Marc Lasgouttes wrote:
> > * I could do fancy things, but I'd rather avoid to import a whole library
> > for this.
>
Probably, the less fancy option is to use std::hash, available since C++11.
I have no idea about the quality of the produced hashes, and it seems it
might really depend on the compiler too.
I can totally understand the need for very unique hashes in this case
(unlike hash tables). If you want something with unicity guarantees, the
only meaningful choice is cryptographic hashes: other functions do not have
the right properties (easy to compute, but no real guarantee with small
hashes). Something like BLAKE2/3 should be good, performance-wise, and it's
available in Qt since Qt 6 (
https://doc.qt.io/qt-6/qcryptographichash.html#Algorithm-enum); otherwise,
Keccak since 5.9; or SHA-3 before.
Otherwise, you might consider using several hashes (concatenating them): I
think it should provide enough entropy to have a very low probability of
collision, but the hash algorithms must be really different for this to be
worthwhile. (Just starting with std::hash and the string length, then see
if more is required?)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20221108/4e1b0eee/attachment.html>
More information about the lyx-devel
mailing list