Saving a password in a file
Hi
I am writing a application, that takes the username and password from the user.
I want to add a feature that helps in remembering the username and password.
What i have thought was, storing the username and password in encrypted form in a file on the disk.
how will Qt support creating the file and storing it?
Where can I store the file? near the app or in My Documents/All User/ ... folder?
one more thing, How can i invoke a pop-up box to accept some text?
thanks
Re: Saving a password in a file
take a look at QCA. then you should provide a master key for encryption users passwords, after that when you encrypt an users password you should to convert encrypted password in base64 (this opperation will help to avoid dencrypt an user password in future, i.e. converting to base64 allows to convert special symbols). then you can store password to a file.
Re: Saving a password in a file
thanks for replying so soon :)
What i need mainly is how to create a file and how to extract the data from it.
Re: Saving a password in a file
there is an example in Qt Assistant, take a look at QFile/QTextStream or QSettings.
Re: Saving a password in a file
Thanks for this.
Isnt there a simple command for it?
Like
File.create(test.txt, $location); to create a file
File.open(file, mode);
File.read(file,start add, no of chars);
File.write(file,mode,string,no of chars);
thanks for ur help :)
Re: Saving a password in a file
Quote:
Originally Posted by
srohit24
What i have thought was, storing the username and password in encrypted form in a file on the disk.
That's generally a bad idea because you have to store the key somewhere...
Quote:
Where can I store the file? near the app or in My Documents/All User/ ... folder?
Store it wherever you want :) QDesktopServices::storageLocation() might be a handy method here.
Quote:
one more thing, How can i invoke a pop-up box to accept some text?
QInputDialog::getText()
Quote:
Originally Posted by
srohit24
Isnt there a simple command for it?
Like
File.create(test.txt, $location); to create a file
File.open(file, mode);
File.read(file,start add, no of chars);
File.write(file,mode,string,no of chars);
Sure there is, use QFile as suggested, although it would probably be better if you used QSettings (as suggested as well).
Re: Saving a password in a file
thanks for helping mate. :)
the getText() thing worked fine.
Both of you have been telling me to use QFile with QSettings, can you just give me a simple example as to how i can accomplish it?
All i need is a simple file that holds 3 lines of text. I need to access all 3 lines, modify it or delete it.
I went through the documentation, there are very few examples and those haven t helped me understand much.
thanks :D
Re: Saving a password in a file
storing to QSettings
Code:
QSetting settings
("settings.ini",
QSettings::IniFormat);
settings.setValue("UserOption/login", "login");
settings.setValue("UserOption/password", "passw");
reading to QSettings
Code:
QSetting settings
("settings.ini",
QSettings::IniFormat);
qDebug() << settings.value("UserOption/login");
qDebug() << settings.value("UserOption/password");
Re: Saving a password in a file
thanks mate. the above code worked according to my needs.
I am trying to get a signal when the checkbox in my app is clicked.
I am using the following code.
connect(ui->checkbox, SIGNAL(stateChanged()),SLOT(checkboxclicked()));
but the function is never called even if i check or uncheck the box
any solutions??
Re: Saving a password in a file
Quote:
Originally Posted by
srohit24
any solutions??
Yepp, read the docs, validate your code... and use the CODE tags of this board!
To your question: You missed this
Code:
connect(ui->checkbox, SIGNAL(stateChanged()), this, SLOT(checkboxclicked()));
and is checkboxclicked declared as a slot?
EDIT: and mybe you also want:
Code:
connect(ui->checkbox, SIGNAL(stateChanged(int)), this, SLOT(checkboxclicked(int)));
Re: Saving a password in a file
Re: Saving a password in a file
I'd use toggled() instead of stateChanged().
Re: Saving a password in a file
Quote:
Originally Posted by
Lykurg
To your question: You missed this
this is not necessary. There is such connect() that takes 3 args: pointer, signal, slot. And that slot should be defined in object ponited by this.
And to srohit24:
please, use CODE tags, and use the Qt Assistant sometimes, did you use it already?