PDA

View Full Version : QCryptographicHash



live_07
21st November 2007, 22:00
Hi,

QByteArray l_byteArray = "hello world";

QCryptographicHash l_crpto( QCryptographicHash::Md5) ;

l_crpto.addData(l_byteArray);

l_byteArray = l_crpto.result();

qDebug<<l_byteArray ; //^╢;╗α▲ε╨?╦"╗Ã…Z═├

again how to convert hash value to bytearray like l_byteArray = "HELLOWORD";

Thanks in advance

jpn
21st November 2007, 22:08
You can use QByteArray::toHex() to obtain hexadecimal representation of the hash, like is shown at http://wiki.qtcentre.org/index.php?title=Cryptography.

live_07
21st November 2007, 22:49
Thanks for reply jpn

but i want text format conversion like l_byteArray = "hello world";

is there way to convert above format in qt?

jpn
22nd November 2007, 09:46
But MD5 is a one-way hash..

bugsstring
20th June 2008, 09:31
Hello all !!
Im noob...
how do this
i have mysql database with table that contain user passwords encrypted by md5
my form have QLineEdit for password but method text() return QString and i cant use
QCryptographicHash pass(QCryptographicHash::Md5);
pass.addData(passwd->text());
what i can do ?

Holy Cheater
21st June 2008, 19:26
pass.result().toHex() - you get md5 string (QByteArray, to be precise) of password entered into the box.
Then you compare that string to the password, which you acquire from the database.