www.pudn.com > CipherSystem.rar > KeyWordProcess.cpp


// KeyWordProcess.cpp : 实现文件 
// 
 
#include "stdafx.h" 
#include "CipherSystem.h" 
#include "KeyWordProcess.h" 
#include ".\keywordprocess.h" 
#include "KeyWordCipherSystem.h" 
#include "GlobalFunctions.h" 
 
 
// KeyWordProcess 对话框 
 
IMPLEMENT_DYNAMIC(KeyWordProcess, CDialog) 
KeyWordProcess::KeyWordProcess(CWnd* pParent /*=NULL*/) 
	: CDialog(KeyWordProcess::IDD, pParent) 
	, m_strKey(_T("")) 
	, m_strShow(_T("")) 
	, m_iMark(0) 
	, m_strStart(_T("a")) 
{ 
} 
 
KeyWordProcess::~KeyWordProcess() 
{ 
} 
 
void KeyWordProcess::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	DDX_Text(pDX, IDC_EDIT1, m_strKey); 
	DDX_Text(pDX, IDC_STATIC_SHOW, m_strShow); 
	DDX_CBString(pDX, IDC_COMBO1, m_strStart); 
} 
 
 
BEGIN_MESSAGE_MAP(KeyWordProcess, CDialog) 
	ON_BN_CLICKED(ID_KEYWORD_ENCRYPT, OnBnClickedKeywordEncrypt) 
	ON_BN_CLICKED(ID_KEYWORD_DECRYPT, OnBnClickedKeywordDecrypt) 
	ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel) 
	ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1) 
END_MESSAGE_MAP() 
 
 
// KeyWordProcess 消息处理程序 
 
void KeyWordProcess::OnBnClickedKeywordEncrypt() 
{ 
	// TODO: 在此添加控件通知处理程序代码 
	UpdateData(TRUE); 
	if (m_strKey.IsEmpty()) 
	{ 
		AfxMessageBox("请输入密钥"); 
		return; 
	} 
	m_iMark = 1; 
	OnOK(); 
} 
 
void KeyWordProcess::OnBnClickedKeywordDecrypt() 
{ 
	// TODO: 在此添加控件通知处理程序代码 
	UpdateData(TRUE); 
	if (m_strKey.IsEmpty()) 
	{ 
		AfxMessageBox("请输入密钥"); 
		return; 
	} 
	m_iMark = -1; 
	OnOK(); 
} 
 
void KeyWordProcess::OnBnClickedCancel() 
{ 
	// TODO: 在此添加控件通知处理程序代码 
	m_iMark = 0; 
	OnCancel(); 
} 
 
void KeyWordProcess::OnBnClickedButton1() 
{ 
	// TODO: 在此添加控件通知处理程序代码 
	UpdateData(TRUE); 
	if (m_strKey.IsEmpty()) 
	{ 
		AfxMessageBox("请输入密钥"); 
		return; 
	} 
 
	KeyWordEncryptSystem mySystem; 
 
	char start = m_strStart[0]; 
	string key; 
	CStringToString(this->m_strKey, key); 
	mySystem.GetKey(key,start); 
 
	m_strShow = "Plaintext:  ABCDEFGHIJKLMNOPQRSTUVWXYZ\n\nCiphertext:"; 
		 
	int i; 
	for (i=0; i<26; i++)  
	{ 
		m_strShow += mySystem.encryptArray[i]; 
		m_strShow += " "; 
	} 
	UpdateData(FALSE); 
}