Click here to Skip to main content
15,891,184 members
Articles / Desktop Programming / MFC

Serializing encrypted data

Rate me:
Please Sign up or sign in to vote.
4.56/5 (3 votes)
31 Oct 20011 min read 80.2K   1.4K   28  
How to serialize encrypted data using CArchive
// FileEx.h: interface for the CFileEx class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_FILEEX_H__F85DCA61_CE1C_11D5_AEE6_00B0D0B8715B__INCLUDED_)
#define AFX_FILEEX_H__F85DCA61_CE1C_11D5_AEE6_00B0D0B8715B__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

typedef UINT (FileEncryptProc)(const BYTE *pBuffer,UINT dwSize,BYTE *pDestination,DWORD dwParam);

class CFileEx  : public CFile
{
public:
	CFileEx(int nBufSize=4096);
	CFileEx(LPCTSTR lpszFileName, UINT nOpenFlags,int nBufSize=4096);
	virtual ~CFileEx();
	virtual UINT Read(void* lpBuf, UINT nCount);
	virtual void Write( const void* lpBuf, UINT nCount );
	void SetEncryption(FileEncryptProc *pEncrypt,DWORD dwEncryptParam,FileEncryptProc *pDecrypt,DWORD dwDecryptParam);
protected:
	BYTE* m_pBuf;
	FileEncryptProc *m_pEncrypt,*m_pDecrypt;
	DWORD	m_dwEncrypt,m_dwDecrypt;
};

#endif // !defined(AFX_FILEEX_H__F85DCA61_CE1C_11D5_AEE6_00B0D0B8715B__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Israel Israel
Gilad was born accidently to a pair of old lesbians. His childhood was full of vibrators and drugs. Married without kids. Has 14 grandsons around the world, 4 crocodiles, 2 mushrooms and a green alien living behind the refrigerator.

Hobbies: Watching hardcore porn, sculpturing with snot, skydiving from stairs.

Check my Homepage for additional resources.

Quote: "There's always one more bug"

Comments and Discussions