Re: Breaking changes in file layout
Tobias Leupold <[email protected]> Mon, 06 Apr 2020 15:51:51 +0200
| Newsgroups | gmane.comp.kde.kimdaba |
|---|---|
| Message-ID | <2280629.jE0xQCEvom@ginuog> |
> Yeah, of course it's no problem to calculate an MD5 or SHA-1 hash from a
> path. I only thought this would give us a long hash, and the checksum used
> here is quite short. Well, of, course, the 8 or whatever leftmost chars of
> the hex representation of a MD5 hash should be do the job as well and would
> also be short.
That would then be something like this (I didn't try the below code):
QString Whatever::dbIdentifier(const QString &indexXml) const
{
const QFileInfo fileInfo(indexXml);
return QStringLiteral("%1-%2").arg(
QString::fromUtf8(QCryptographicHash::hash(
indexXml.toUtf8(),
QCryptographicHash::Md5).toHex()).left(8),
fileInfo.dir().dirName());
}