View Full Version : How to secure a file by password
miraks
23rd January 2009, 22:14
Hi,
I am writing an application which must be to open a file protected by a user password.
What is the best solution to secure a file by password ?
I imagine to copy the secured file (encrypted) into a temporary file not secured and open it. But how to do ?
Thank you in advance.
wysota
23rd January 2009, 22:27
If you intend to copy the contents of a file to an unencrypted file, then don't encrypt it at all :)
I suggest you use some cryptographic streaming algorithm. I have once implemented a RC4 cipher as a QIODevice but you may use some ready made solutions (such as libcrypt from OpenSSL) that will decipher contents of a file into memory where you can access it, read it and wipe it out from memory when you don't need it anymore.
rleojoseph
21st March 2011, 09:18
what class file can be used to encyrpt a file ????????
miraks
21st March 2011, 10:41
I am using QCA.
rleojoseph
22nd March 2011, 05:47
Hi, i am creating a texteditor using QT. I was trying to set a password for a file. What mechanism or class should i use to set a password for a file ??
Can you give me a minimal example that how i can make use of it in my project ??
Added after 55 minutes:
What is the QFile::EncoderFn and QFile::DecoderFn used for ??
squidge
22nd March 2011, 08:12
Depends on your specification - do you want to add a password to a file, or encrypt a file to protect the file being opened without the password ?
rleojoseph
22nd March 2011, 08:28
Ya. I want to add password for a file so that it will be opened if the password is correct.
squidge
22nd March 2011, 10:09
As stated before the threads were merged, use the Qt Cryptographic Architecture.
How to use QCA depends on your specifications - the first thing you need is a cipher, and then you need to decide how to encrypt/decrypt the data using your password.
miraks
22nd March 2011, 19:34
You can find an example here: http://quickgit.kde.org/?p=skrooge.git&a=blob_plain&h=5f853d111898d1774072d4e06604d64f0e6291c8&f=skgbasemodeler/skgservices.cpp, in function SKGServices::cryptFile.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.