⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 decodetestdlg.cpp

📁 根据pudn下载的几个源代码
💻 CPP
字号:
// DecodeTestDlg.cpp : implementation file
//

#include "stdafx.h"
#include "DecodeTest.h"
#include "DecodeTestDlg.h"

#include "md5.h"
#include "d3des.h"
#include <iostream>
using namespace std;

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDecodeTestDlg dialog

CDecodeTestDlg::CDecodeTestDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CDecodeTestDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDecodeTestDlg)
	m_sPassWord = _T("123456");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CDecodeTestDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDecodeTestDlg)
	DDX_Text(pDX, IDC_EDIT_PASSWORD, m_sPassWord);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CDecodeTestDlg, CDialog)
	//{{AFX_MSG_MAP(CDecodeTestDlg)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BTN_ENCODE, OnBtnEncode)
	ON_BN_CLICKED(IDC_BTN_DESCODE, OnBtnDescode)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDecodeTestDlg message handlers

BOOL CDecodeTestDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CDecodeTestDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CDecodeTestDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

//==============encode test===========//
void CDecodeTestDlg::OnBtnEncode() 
{
	UpdateData(TRUE);
	if (m_sPassWord.GetLength() == 0)
	{
		MessageBox("Please input password firstly");
		return;
	}
	CString EncodedName;
	CFileDialog FileDlg(true,NULL, NULL,OFN_HIDEREADONLY |OFN_OVERWRITEPROMPT,"*.*||*.*");
	FileDlg.m_ofn.lpstrTitle="Input encoded file";   //打开文件对话框标题
	if(FileDlg.DoModal() == IDOK)
	{		
		EncodedName = FileDlg.GetPathName();
	}
	else
	{
		return;
	}

	char *plainFile;
	plainFile   =   (LPTSTR)(LPCTSTR)EncodedName;
	
	char *password;
	password = (LPTSTR)(LPCTSTR)m_sPassWord;
	
	CString CipherFileName;
	CFileDialog FileDlg2(true,NULL, NULL,OFN_HIDEREADONLY |OFN_OVERWRITEPROMPT,"*.*||*.*");
	FileDlg2.m_ofn.lpstrTitle="Input Generating cipher file";   //打开文件对话框标题
	if(FileDlg2.DoModal() == IDOK)
	{		
		CipherFileName = FileDlg2.GetPathName();
	}
	else
	{
		return;
	}
	char *cipherFile;
	cipherFile = (LPTSTR)(LPCTSTR)CipherFileName;

	if (!D3DESFile(plainFile, cipherFile, password, EN0))
	{
		MessageBox("Error which Generating cipher file!","D3DESFile");
		return;
	}
	else
	{
		MessageBox("File encoded completed!");
	}

}

void CDecodeTestDlg::OnBtnDescode() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	if (m_sPassWord.GetLength() == 0)
	{
		MessageBox("Please input password firstly");
		return;
	}
	CString DecryptFileName;
	CFileDialog FileDlg1(true,NULL, NULL,OFN_HIDEREADONLY |OFN_OVERWRITEPROMPT,"*.*||*.*");
	FileDlg1.m_ofn.lpstrTitle="Input need Decrypt file";   //打开文件对话框标题
	if(FileDlg1.DoModal() == IDOK)
	{		
		DecryptFileName = FileDlg1.GetPathName();
	}
	else
	{
		return;
	}

	char *cipherFile;
	cipherFile = (LPTSTR)(LPCTSTR)DecryptFileName;

	CString EncodedName;
	CFileDialog FileDlg(true,NULL, NULL,OFN_HIDEREADONLY |OFN_OVERWRITEPROMPT,"*.*||*.*");
	FileDlg.m_ofn.lpstrTitle="Input generating decrypted file";   //打开文件对话框标题
	if(FileDlg.DoModal() == IDOK)
	{		
		EncodedName = FileDlg.GetPathName();
	}
	else
	{
		return;
	}
	
	char *plainFile;
	plainFile   =   (LPTSTR)(LPCTSTR)EncodedName;
	
	char *password;
	password = (LPTSTR)(LPCTSTR)m_sPassWord;
	
	if (!D3DESFile(cipherFile, plainFile, password, DE1))
	{
		MessageBox("Error which Generating decrypt file!","D3DESFile");
		return;
	}
	else
	{
		MessageBox("File decrypt completed!");
	}

		
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -