简体   繁体   中英

saving password in cpp application

Working on a Qt application on embedded linux which requires to store the username, password kind of sensitive information.

I'm currently using QStringLiteral to store this info. Is this safe to do? These aren't visible when ran against strings binary. What are the available options / solutions?

SqlCipher is available but again it needs a password / key. Any suggestions

You should never store passwords! There is no way to do that securely, not in Qt nor in anywhere else!

I would recommend you to generate a random number/salt, add the password from the user and run a secure hash on that data. For example MD5, or even better SHA1 (thanks to Ted Lyngmo). Store the result. Then you can even take a plain text file as it is very hard to get from that data back to the original password.

If security is not that big for you, you could use something like:

QString result = QString(QCryptographicHash::hash((password+salt),QCryptographicHash::Md5).toHex());

and safe the result in QSettings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM