Storing A hex value as a string?
Hi this is the code i have:
Code:
QByteArray hash
= QCryptographicHash
::hash((ui
->PasswordTextbox
->text
()).
toUtf8(), QCryptographicHash
::Md5);
qDebug() << hash.toHex();
string password = // The code I need here
What I am trying to do is when the user enters the password, it gets encrypted with Md5. Then I want this md5 encrypted version to get stored as a string.
For example if the user enters '1234' as their password it gets converted to '81dc9bdb52d04dc20036dbd8313ed055'. This is outputted to the debugger using hash.toHex(); at the moment. I want this value to then be stored to a string so i can compare it against a password stored in a database.
how do i store the value '81dc9bdb52d04dc20036dbd8313ed055' to a string?
Thanks for your time and trouble
Re: Storing A hex value as a string?
Hi there!
How about using the constructor of QString, that takes a QByteArray as parameter?
Code:
QByteArray hash
= QCryptographicHash
::hash(QString("1234").
toUtf8(), QCryptographicHash
::Md5);
qDebug() << password;
HIH
Joh
Re: Storing A hex value as a string?
I would also suggest you salt your password before running it through md5.
Re: Storing A hex value as a string?
Re: Storing A hex value as a string?
Thank you this is now working great. I will salt my password. I just wanted to get this to work before i added anymore code which could have further confused me!!
Once again thanks :D