Click here to Skip to main content
15,886,026 members
Articles / Desktop Programming / MFC

A simple MFC class to encrypt data with the Crypto API

Rate me:
Please Sign up or sign in to vote.
4.84/5 (14 votes)
3 Jul 2007GPL39 min read 150K   6.2K   71  
An article showing how to use the Crypto API to make a simple MFC class that can encrypt and decrypt different types of data
// ExampleDlg.h : header file
//

#pragma once

#include "Crypto.h"

// CExampleDlg dialog
class CExampleDlg : public CDialog
{
// Construction
public:
	CExampleDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_EXAMPLE_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()

public:

	//	The crypto object.
	MFC::CCrypto m_crypto;

	CString m_strPassword;
	CString m_strData;

protected:
	virtual void OnOK();
public:
	afx_msg void OnBnClickedButtonLoad();
public:
	afx_msg void OnBnClickedButtonSave();
};

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, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Software Developer
United Kingdom United Kingdom
Follow my blog at www.dwmkerr.com and find out about my charity at www.childrenshomesnepal.org.

Comments and Discussions