Incorrect MD5 Digest for Thumbnail File Name
David Bowen
David at MyForest.Com
Sun Apr 23 00:46:20 BST 2006
Sorry to mail you all. I asked on #konqueror and <apachelogger> was kind
enough to direct me to this mailing list.
I'm trying to re-use the KDE thumbnails. The quick version is: "My MD5 digest
is different to the file name of the thumbnail generated by Konqueror."
In detail:
I'm using the "Thumbnail Managing Standard" as my guide:
http://jens.triq.net/thumbnail-spec/
Jens says that "file:///home/jens/photos/me.png" gives
"c6ee772d9e49320e97ec29a7eb5b1697". I concur with this - using both the md5sum
program and my own Java code.
I then get my code (and md5sum) to generate a digest for:
file:///files/shared/secure/david/My Documents/bookmarks.html
and we have "223e9e18d9949be1d93742ef755d75dc". Unfortunately, when I look in
"~/.thumbnails" I see the file generated by Konqueror is called
"a6d43f0e68cbab3fd3b80713afce3916.png". I'm not sure what is causing the
discrepancy. I've tried a number of different URIs but none of them give
"a6d43f0e68cbab3fd3b80713afce3916".
In an attempt to see what I was doing wrong I looked at the preview job code
at:
http://lxr.kde.org/source/KDE/kdelibs/kio/kio/previewjob.cpp?v=3.5-branch#384
(I'm running KDE 3.5.2-0.1.fc5 Red Hat). It looks much like my Java code
except for the call to "encodeName" which can be found at:
http://lxr.kde.org/source/KDE/kdebindings/kjsembed/builtins/qfile_imp.cpp?v=3.5-branch#546
This then leads to QFile::encodeName at:
http://doc.trolltech.com/3.3/qfile.html#encodeName
and I'm afraid that's where things get beyond my understanding.
Looking on the kfm-devel mail archive I found a single message which suggests
things are as I expect:
http://lists.kde.org/?l=kfm-devel&m=101732994904708&w=2
So clearly I'm doing something wrong as the URI I'm supplying to the MD5
algorithm is not the same as the Konqueror one. I'm going to take a punt and
post the Java I'm using (in a Java Server page). I'm not looking for help with
that - I'm just adding it as reference.
import="java.util.*"
import="java.security.MessageDigest"
MessageDigest md = MessageDigest.getInstance("MD5");
String uri ="file:///files/shared/secure/david/My Documents/bookmarks.html";
md.update(uri.getBytes());
byte[] md5Hash = md.digest();
StringBuffer sb = new StringBuffer();
for (int byteIndex = 0; byteIndex < md5Hash.length; ++byteIndex) {
sb.append(Integer.toHexString((md5Hash[byteIndex] & 0xFF) |
0x100).toUpperCase().substring(1,3));
}
String md5HashString =sb.toString().toLowerCase();
I'd be grateful if someone could point me in the right direction to understand
the correct format for the URI. I should also mention that this file is on an
NFS share just in case some extra resolution takes place in such a case.
Thanks for your time
David Bowen
More information about the kfm-devel
mailing list