Unsolved help write code
-
I created lineEdit, button, and password generator engine , password is generated in lineEdit, and so, when I click this button, I want to save the password in a .txt file. Who can write such code.
My Qt version is 5.14 -
@Qwerty123098 said in help write code:
Who can write such code.
You can! See https://doc.qt.io/qt-5/qfile.html (there is a paragraph that starts with "To write text")
P.S.
I want to save the password in a .txt file
usually you don't save the password but a
QCryptographicHash
of the password for security reasons -
no, in the sense of the text that is written in lineEdit to save in a .txt file in a directory by clicking on the "Save file" button
-
Use your
lineEdit->text()
, convert it to aQByteArray
and then generate aQCryptographicHash
(like @VRonin mentioned above) from it. Afterwards you can store this in your txt-file.To do so, you open your file or create a new one and write your array to file.
QFile file("PATH/pw.txt"); if (file.open(QIODevice::WriteOnly)) { file.write(YourByteArray); file.close(); }
@Qwerty123098 said in help write code:
text that is written in lineEdit save in a .txt file in a directory
Just normal text you dont need to encrypt or hash, but you dont want to do this with real passwords and save them as plain text in a txt-file on your drive.
-
@Pl45m4 save by clicking on the "Save file" button
-
Connect your button (clicked signal) with your slot / function and put your code there.
https://doc.qt.io/qt-5/signalsandslots.html -
Thank you