[Qt-interest] QCryptographicHash and md5sum

Boudewijn Rempt boud at valdyas.org
Fri Jan 23 14:39:39 CET 2009


On Fri, 23 Jan 2009, Boudewijn Rempt wrote:

> If I do an md5sum on a file, I get a certain result, say
> 24a9df02e3fe1e4782ddb97d603afd2e, but if I download that file 
> to a temporary file and apply the following code:
> 
> QByteArray md5 = QCryptographicHash::hash(temporaryFile->readAll(), QCryptographicHash::Md5);
> 
> Then md5.toHex() gives me a quite different result.
> 
> Which I didn't expect... What did I miss?

Got it - I needed to do a temporaryFile->reset() -- apparently,
it wasn't at start when I tried to compute the digest.

Boudewijn




More information about the Qt-interest-old mailing list