Fabiotk Fabiotk - 9 months ago 54
C++ Question

Any c++ library to work with Md5 using class string?

Is there any c++ standard library to work with Md5 hashing (and other hashes, possibly) by using the c++

instead of
signed\unsigned char*
?. I found no implementation of this in
since its function MD5 has this header:
unsigned char *MD5(const unsigned char *d, unsigned long n, unsigned char *md);

I'm asking this because I'm trying to set a
QLabel lbResult
's text to the result of the digest of the input of a string (coming from QString& arg1).

MD5((const unsigned char *) arg1.toStdString().c_str(),32,cryptResult);

I had to build this
which returns a
object from the result but all these casting and this function could be avoided if I had something line
string MD5(string s);
. Thanks in advance.


You can use QCryptographicHash. For example:

QByteArray hash = QCryptographicHash::hash(arg1.toUtf8(), QCryptographicHash::Md5);