Hashing without relying on Qt?

Thibaut Cuvelier tcuvelier at lyx.org
Sat Oct 16 21:15:41 UTC 2021


Dear list,

In my last patch (21366155), I added a dependency from InsetText to Qt to
be able to generate SHA hashes. The main goal is to have an
almost-collision-free name-generation technique, which is a great
useability enhancement, that's why I already pushed the patch. Collisions
would be awful, because two different insets would have the same file name.

I don't think Bernstein's hash (in Author.cpp) would fit the bill: it
doesn't go to great lengths to avoid collisions (it has a lot for strings:
https://softwareengineering.stackexchange.com/questions/49550/which-hashing-algorithm-is-best-for-uniqueness-and-speed
).

UUID/GUID are mostly time-based or use cryptographic hash functions: they
do not really depend on the content, but mostly on time, and I need that
the file names remain constant in time (unless the LaTeX code that is
compiled gets changed).

CityHash would be enough, but that's another dependency to add to LyX (
https://github.com/google/cityhash).

The only solution I found without importing a large new dependency into LyX
was to use Qt's QCryptographicHash, just like support/FileName.cpp. I know
that LyX tries to have clear boundaries for dependencies, that's why I'm
bringing the question to the list. Is the current solution acceptable?
Maybe move some of the code to support/FileName.cpp?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20211016/0e573eb1/attachment.html>


More information about the lyx-devel mailing list