Fabiotk Fabiotk - 1 year ago 145
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.

Answer Source

You can use QCryptographicHash. For example:

QByteArray hash = QCryptographicHash::hash(arg1.toUtf8(), QCryptographicHash::Md5);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download