Using QCryptographicHash in qt c++
-
wrote on 18 Feb 2022, 09:20 last edited by
I have a string that I write and read inside the text file. I want to encrypt this strig. Do I have to use the QCryptographicHash library for this? If I need to use QCryptographicHash can you give me an example of that?
-
wrote on 18 Feb 2022, 09:35 last edited by Bonnie
QCryptographicHash is just for hashing (MD5, SHA1...), not for encrypting / decrypting.
You can use it if you don't need to decrypt the string. -
I have a string that I write and read inside the text file. I want to encrypt this strig. Do I have to use the QCryptographicHash library for this? If I need to use QCryptographicHash can you give me an example of that?
wrote on 18 Feb 2022, 09:57 last edited by JonB@TheCeylann
As @Bonnie has said, you cannot useQCryptographicHash
if you really need to decrypt at a later date. It is for one-way, asymmetric encryption: it can be used to check that the user supplies the same encryption password at a later date as they did when originally encrypting the string, but can never retrieve the original, plain-text string.If you need to be able to get the original plain-text back at a later date you must use a two-way, symmetric encryption algorithm, which is not "secure". Qt does not pre-supply such code. An example of such an algorithm, which can be used easily with Qt, is given in Simple encryption with SimpleCrypt.
3/3