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

📄 verifydlg.cpp

📁 DES查分攻击源代码
💻 CPP
字号:
// VerifyDlg.cpp : implementation file
//

#include "stdafx.h"
#include "DesDemo.h"
#include "VerifyDlg.h"
#include "Des.h"

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

/////////////////////////////////////////////////////////////////////////////
// CVerifyDlg dialog


CVerifyDlg::CVerifyDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CVerifyDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CVerifyDlg)
	//}}AFX_DATA_INIT

	m_nCryTextLength = 0;
	m_pCryText = NULL;
	memset(m_cCrackKey,'\0',9);
	memset(m_cOrgKey,'\0',9);
}


void CVerifyDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CVerifyDlg)
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CVerifyDlg, CDialog)
	//{{AFX_MSG_MAP(CVerifyDlg)
	ON_BN_CLICKED(IDC_BUTTON_CRY, OnButtonCry)
	ON_BN_CLICKED(IDC_BUTTON_DEC, OnButtonDec)
	ON_WM_DESTROY()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CVerifyDlg message handlers

void CVerifyDlg::OnButtonCry() 
{
	CDes des(3);	
	m_nCryTextLength = GetDlgItem(IDC_EDIT_P1)->GetWindowTextLength();	
	while((m_nCryTextLength%8)!=0)
		m_nCryTextLength++;

	if(m_pCryText)
		delete[] m_pCryText;
	m_pCryText = new char[m_nCryTextLength+1];
	memset(m_pCryText,'\0',(m_nCryTextLength+1));
	char *pPlain = new char[m_nCryTextLength+1];
	memset(pPlain,0,m_nCryTextLength+1);
	GetDlgItem(IDC_EDIT_P1)->GetWindowText(pPlain,m_nCryTextLength+1);
	des.Encrypt(m_pCryText,pPlain,m_nCryTextLength,m_cOrgKey,8);

	GetDlgItem(IDC_EDIT_C1)->SetWindowText(m_pCryText);
	GetDlgItem(IDC_EDIT_C2)->SetWindowText(m_pCryText);
	delete pPlain;
}

void CVerifyDlg::OnButtonDec() 
{
	CDes des(3);
	char *pPlain = new char[m_nCryTextLength+1];
	memset(pPlain,'\0',m_nCryTextLength+1);
	des.Decode(pPlain,m_pCryText,m_nCryTextLength,m_cCrackKey,8);
	GetDlgItem(IDC_EDIT_P2)->SetWindowText(pPlain);
	delete pPlain;
}

BOOL CVerifyDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	
	GetDlgItem(IDC_EDIT_ORGKEY)->SetWindowText(m_cOrgKey);
	GetDlgItem(IDC_EDIT_CRACKKEY)->SetWindowText(m_cCrackKey);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CVerifyDlg::OnDestroy() 
{
	CDialog::OnDestroy();
	if(m_pCryText)
		delete m_pCryText;
}

⌨️ 快捷键说明

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