Go4Expert

Go4Expert (http://www.go4expert.com/)
-   MFC (http://www.go4expert.com/forums/mfc/)
-   -   Encryption Mechanism in MFC. (http://www.go4expert.com/forums/encryption-mechanism-mfc-t8400/)

Gurjeet Singh Batth 22Jan2008 14:53

Encryption Mechanism in MFC.
 
Hello Everybody,

I am writing an application that need Encryption. Is there any Encryption Mechanism provided
by MFC?


Thanks

Gurjeet Singh Batth 23Jan2008 15:36

Re: Encryption Mechanism in MFC.
 
Hello Everybody...
I have used the following code snippet to encrypt a file.
Everything is going fine. According to the concept I have successfully encrypted the file.

Code:

void CFileEncryptDlg::OnBnClickedButton1()
{
        CString sTest= "Are you here? I wanna talk to you. This is a pretty Serious issue.";
        CFile Myfile;
        Myfile.Open ("C:\\Test.fen",CFile ::modeCreate |CFile::modeWrite );
        Myfile.Write (sTest ,sTest.GetAllocLength ());
        Myfile .Close ();

        /*EncryptFile function is an inbuilt function to Encrypt the file*/
        int ret = EncryptFile ("C:\\Test.fen");
        int lastError = GetLastError ();
       
        /* Checking the file status whether it got encrypted or not*/
        DWORD ATT = GetFileAttributes ("C:\\test.fen");
 
            if (ATT & FILE_ATTRIBUTE_ENCRYPTED )
              {
                MessageBox ("Encrypted");
              }

        lastError = GetLastError ();
}

But when I open this file in Notepad it still opens and text is still readable.This is the trouble.
If it is to remain readable, then what is fun of EncryptFile() provided by Platform SDK.

Gurjeet Singh Batth 25Jan2008 17:03

Re: Encryption Mechanism in MFC.
 
Hi everybody.
This is the link where I found my answers. Thus want to share it with you people too.

http://msdn.microsoft.com/library/de...ing_a_file.asp
This article explains File Encryption/ Decryption .
Thanks.


All times are GMT +5.5. The time now is 01:34.