?? deslancedlg.cpp
字號:
// DESLANCEDlg.cpp : implementation file
//
#include "stdafx.h"
#include "DESLANCE.h"
#include "DESLANCEDlg.h"
#include "function.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDESLANCEDlg dialog
CDESLANCEDlg::CDESLANCEDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDESLANCEDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDESLANCEDlg)
m_ciphertext = _T("");
m_mima = _T("");
m_deciphertext = _T("");
m_plaintext = _T("");
m_f0 = 0;
m_f1 = 0;
m_f10 = 0;
m_f11 = 0;
m_f12 = 0;
m_f13 = 0;
m_f2 = 0;
m_f3 = 0;
m_f4 = 0;
m_f5 = 0;
m_f6 = 0;
m_f7 = 0;
m_f8 = 0;
m_f9 = 0;
m_t0 = 0;
m_t1 = 0;
m_t10 = 0;
m_t11 = 0;
m_t12 = 0;
m_t13 = 0;
m_t2 = 0;
m_t3 = 0;
m_t4 = 0;
m_t5 = 0;
m_t6 = 0;
m_t7 = 0;
m_t8 = 0;
m_t9 = 0;
m_keytype = -1;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CDESLANCEDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDESLANCEDlg)
DDX_Text(pDX, IDC_CIPHER, m_ciphertext);
DDX_Text(pDX, IDC_KEY, m_mima);
DDX_Text(pDX, IDC_DCIPHER, m_deciphertext);
DDX_Text(pDX, IDC_PLAIN, m_plaintext);
DDX_Text(pDX, IDC_F0, m_f0);
DDX_Text(pDX, IDC_F1, m_f1);
DDX_Text(pDX, IDC_F10, m_f10);
DDX_Text(pDX, IDC_F11, m_f11);
DDX_Text(pDX, IDC_F12, m_f12);
DDX_Text(pDX, IDC_F13, m_f13);
DDX_Text(pDX, IDC_F2, m_f2);
DDX_Text(pDX, IDC_F3, m_f3);
DDX_Text(pDX, IDC_F4, m_f4);
DDX_Text(pDX, IDC_F5, m_f5);
DDX_Text(pDX, IDC_F6, m_f6);
DDX_Text(pDX, IDC_F7, m_f7);
DDX_Text(pDX, IDC_F8, m_f8);
DDX_Text(pDX, IDC_F9, m_f9);
DDX_Text(pDX, IDC_T0, m_t0);
DDX_Text(pDX, IDC_T1, m_t1);
DDX_Text(pDX, IDC_T10, m_t10);
DDX_Text(pDX, IDC_T11, m_t11);
DDX_Text(pDX, IDC_T12, m_t12);
DDX_Text(pDX, IDC_T13, m_t13);
DDX_Text(pDX, IDC_T2, m_t2);
DDX_Text(pDX, IDC_T3, m_t3);
DDX_Text(pDX, IDC_T4, m_t4);
DDX_Text(pDX, IDC_T5, m_t5);
DDX_Text(pDX, IDC_T6, m_t6);
DDX_Text(pDX, IDC_T7, m_t7);
DDX_Text(pDX, IDC_T8, m_t8);
DDX_Text(pDX, IDC_T9, m_t9);
DDX_CBIndex(pDX, IDC_COMBO1, m_keytype);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDESLANCEDlg, CDialog)
//{{AFX_MSG_MAP(CDESLANCEDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDOK, On_OK)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDESLANCEDlg message handlers
BOOL CDESLANCEDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// 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
}
void CDESLANCEDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// 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 CDESLANCEDlg::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 CDESLANCEDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CDESLANCEDlg::On_OK()
{
UpdateData();
char mima[16],plaintext[MAXLEN],ciphertext[MAXLEN],deciphertext[MAXLEN];
int miyao[NUM1];
int i,n,k;
for(i=0;i<14;i++)
{ t[i]=0;
f[i]=0;
}
if(m_keytype==-1) {
AfxMessageBox("Please choose the key type first!");
return;
}
else {if(!m_keytype) {
for(i=0;i<8;i++)
mima[i]=m_mima.GetAt(i);
change1(mima,miyao,8);
k=key_setup(miyao);
if(k) {
AfxMessageBox("It's a week mima.Please input again.\n");
return;
}
}
else {
for(i=0;i<16;i++)
mima[i]=m_mima.GetAt(i);
for(i=0;i<16;i++)
HTB(mima[i],&(miyao[i*4]));
k=key_setup(miyao);
if(k) {
AfxMessageBox("It's a week mima.Please input again.\n");
return;
}
}
}
AfxMessageBox("Setup key success!");
n=m_plaintext.GetLength();
for(i=0;i<n;i++)
plaintext[i]=m_plaintext.GetAt(i);
DES(plaintext,ciphertext,deciphertext,n);
ciphertext[n]='\0';
deciphertext[n]='\0';
m_ciphertext.Format("%s",ciphertext);
m_deciphertext.Format("%s",deciphertext);
m_f0=f[0]; m_f1=f[1]; m_f2=f[2]; m_f3=f[3]; m_f4=f[4]; m_f5=f[5]; m_f6=f[6];
m_f7=f[7]; m_f8=f[8]; m_f9=f[9]; m_f10=f[10]; m_f11=f[11]; m_f12=f[12]; m_f13=f[13];
m_t0=t[0]; m_t1=t[1]; m_t2=t[2]; m_t3=t[3]; m_t4=t[4]; m_t5=t[5]; m_t6=t[6];
m_t7=t[7]; m_t8=t[8]; m_t9=t[9]; m_t10=t[10]; m_t11=t[11]; m_t12=t[12]; m_t13=t[13];
UpdateData(false);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -