// ShiYan2Dlg.cpp : 实现文件
//
#include "stdafx.h"
#include "ShiYan2.h"
#include "ShiYan2Dlg.h"
#include "CVigenere.h"
#include "CAuto.h"
#include "CPlayfair.h"
#include "CRC4.h"
#include "RC4Dlg.h"
#include "CsDlg.h"
#include "CCaesar.h"
#include "RC5Dlg.h"
#include "Cs1.h"
#include "CClumn.h"
#include "PERDlg.h"
#include "CPermu.h"
#include "CKeyWord.h"
#include "CDes.h"
#include "DesEDlg.h"
#include "DesDDlg.h"
#include "RsaSeet.h"
#include "CRsa.h"
#include "RsadDlg.h"
#include "RsaeDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// 用于应用程序“关于”菜单项的 CAboutDlg 对话框
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// 对话框数据
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
// 实现
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
// CShiYan2Dlg 对话框
CShiYan2Dlg::CShiYan2Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CShiYan2Dlg::IDD, pParent)
, key_jia(_T(""))
, key_jie(_T(""))
, r_jia(2)
, r_jie(1)
, jia_path(_T(""))
, jie_path(_T(""))
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
p7=false;
p0=false;
p17=false;
p10=false;
p5=false;
p15=false;
p8=false;
p18=false;
p9=false;
p19=false;
key_cs=0;
key_pe=1;
}
void CShiYan2Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT3, key_jia);
DDV_MaxChars(pDX, key_jia, 256);
DDX_Text(pDX, IDC_EDIT4, key_jie);
DDV_MaxChars(pDX, key_jie, 256);
DDX_Radio(pDX, IDC_RADIO1, r_jia);
DDX_Radio(pDX, IDC_RADIO11, r_jie);
DDX_Text(pDX, IDC_EDIT1, jia_path);
DDX_Text(pDX, IDC_EDIT2, jie_path);
}
BEGIN_MESSAGE_MAP(CShiYan2Dlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDC_RADIO1, &CShiYan2Dlg::OnBnClickedRadio1)
ON_BN_CLICKED(IDC_BL_A, &CShiYan2Dlg::OnBnClickedBlA)
ON_BN_CLICKED(IDC_BCIPHER, &CShiYan2Dlg::OnBnClickedBcipher)
ON_BN_CLICKED(IDC_RADIO2, &CShiYan2Dlg::OnBnClickedRadio2)
ON_BN_CLICKED(IDC_RADIO3, &CShiYan2Dlg::OnBnClickedRadio3)
ON_BN_CLICKED(IDC_RADIO4, &CShiYan2Dlg::OnBnClickedRadio4)
ON_BN_CLICKED(IDC_RADIO5, &CShiYan2Dlg::OnBnClickedRadio5)
ON_BN_CLICKED(IDC_RADIO6, &CShiYan2Dlg::OnBnClickedRadio6)
ON_BN_CLICKED(IDC_RADIO7, &CShiYan2Dlg::OnBnClickedRadio7)
ON_BN_CLICKED(IDC_RADIO8, &CShiYan2Dlg::OnBnClickedRadio8)
ON_BN_CLICKED(IDC_RADIO9, &CShiYan2Dlg::OnBnClickedRadio9)
ON_BN_CLICKED(IDC_RADIO10, &CShiYan2Dlg::OnBnClickedRadio10)
ON_BN_CLICKED(IDC_BL_E, &CShiYan2Dlg::OnBnClickedBlE)
ON_BN_CLICKED(IDC_RADIO11, &CShiYan2Dlg::OnBnClickedRadio11)
ON_BN_CLICKED(IDC_RADIO12, &CShiYan2Dlg::OnBnClickedRadio12)
ON_BN_CLICKED(IDC_RADIO13, &CShiYan2Dlg::OnBnClickedRadio13)
ON_BN_CLICKED(IDC_RADIO14, &CShiYan2Dlg::OnBnClickedRadio14)
ON_BN_CLICKED(IDC_RADIO15, &CShiYan2Dlg::OnBnClickedRadio15)
ON_BN_CLICKED(IDC_RADIO16, &CShiYan2Dlg::OnBnClickedRadio16)
ON_BN_CLICKED(IDC_RADIO17, &CShiYan2Dlg::OnBnClickedRadio17)
ON_BN_CLICKED(IDC_RADIO18, &CShiYan2Dlg::OnBnClickedRadio18)
ON_BN_CLICKED(IDC_RADIO19, &CShiYan2Dlg::OnBnClickedRadio19)
ON_BN_CLICKED(IDC_RADIO20, &CShiYan2Dlg::OnBnClickedRadio20)
ON_BN_CLICKED(IDC_BENCIPHER, &CShiYan2Dlg::OnBnClickedBencipher)
ON_BN_CLICKED(IDC_BRSAKEY, &CShiYan2Dlg::OnBnClickedBrsakey)
ON_BN_CLICKED(IDC_BUTTON1, &CShiYan2Dlg::OnBnClickedButton1)
ON_BN_CLICKED(IDCANCEL, &CShiYan2Dlg::OnBnClickedCancel)
END_MESSAGE_MAP()
// CShiYan2Dlg 消息处理程序
BOOL CShiYan2Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 将“关于...”菜单项添加到系统菜单中。
// IDM_ABOUTBOX 必须在系统命令范围内。
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
BOOL bNameValid;
CString strAboutMenu;
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
ASSERT(bNameValid);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
// 执行此操作
SetIcon(m_hIcon, TRUE); // 设置大图标
SetIcon(m_hIcon, FALSE); // 设置小图标
// TODO: 在此添加额外的初始化代码
////这是图片载入的代码
//加密文件载入图标
Bfile_load_a.SubclassDlgItem(IDC_BL_A,this);
Bfile_load_a.SetIcon(IDI_ICON1);
//解密文件载入图片
Bfile_load_e.SubclassDlgItem(IDC_BL_E,this);
Bfile_load_e.SetIcon(IDI_ICON2);
//加密按钮图片
Bjiami.SubclassDlgItem(IDC_BCIPHER,this);
Bjiami.SetIcon(IDI_ICON3);
//解密按钮图片
Bjiemi.SubclassDlgItem(IDC_BENCIPHER,this);
Bjiemi.SetIcon(IDI_ICON4);
//RSA
KEY.SubclassDlgItem(IDC_BRSAKEY,this);
KEY.SetIcon(IDI_ICON4);
//MIN
MIN.SubclassDlgItem(IDC_BUTTON1,this);
MIN.SetIcon(IDI_ICON6);
//tuichu
Exit.SubclassDlgItem(IDCANCEL,this);
Exit.SetIcon(IDI_ICON5);
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
}
void CShiYan2Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// 如果向对话框添加最小化按钮,则需要下面的代码
// 来绘制该图标。对于使用文档/视图模型的 MFC 应用程序,
// 这将由框架自动完成。
void CShiYan2Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // 用于绘制的设备上下文
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// 使图标在工作区矩形中居中
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;
// 绘制图标
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
//当用户拖动最小化窗口时系统调用此函数取得光标
//显示。
HCURSOR CShiYan2Dlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
char* CShiYan2Dlg::zhuanhuan(CFile &file)//文件相关函数不用引用会出错
{
DWORD i;
DWORD j,k=0,h=0;
CString str;
i=file.GetLength();
char *DuQu;
DuQu=new char[i];
char *a;
a=new char[1];
a[1]='\0';
for(j=0;j<i;j++)
{
file.Seek(j,CFile::begin);
CString str;
file.Read(a,1);
if(isascii(a[0])==0)
{
if(h==0)
AfxMessageBox(_T("对不起,因为文本内含有非法字符所以导致加密不完善,请理解!\n我们将忽略非ASCII码的字符!"),
0,MB_OK);
h++;
j++;
continue;
}
if(isalpha(a[0])==0)
{
continue;
}
DuQu[k]=a[0];
k++;
}
DuQu[k]='\0';
return DuQu;
}
char* CShiYan2Dlg::CStringToChar(CString str)
{
char *temp=new char[str.GetLength()];
int i;
for(i=0;i<str.GetLength();i++)
temp[i]=str[i];
temp[i]='\0';
return temp;
}
bool CShiYan2Dlg::keyright(CString k)
{
int i;
int len_k=k.GetLength();
for(i=0;i<len_k;i++)
{
if(k[i]<97||k[i]>122)
{
return 0;
}
}
return 1;
}
bool CShiYan2Dlg::keyright(CString k,int a)
{
int i;
int len_k=k.GetLength();
for(i=0;i<len_k;i++)
{
if(!isascii(k[i]))
{
return 0;
}
}
return 1;
}
void CShiYan2Dlg::OnBnClickedRadio1()
{
// TODO: Add your control notification handler code here
r_jia=0;
GetDlgItem(IDC_EDIT3)->EnableWindow(FALSE);
GetDlgItem(IDC_EDIT3)->SetWindowText(_T(""));
GetDlgItem(IDC_BL_A)->EnableWindow(TRUE);
p7=false;
p0=true;
p5=false;
p8=false;
p9=false;
CCsDlg csdlg;
csdlg.DoModal();
key_jia.Format(_T("%d"),csdlg.key_cs);
GetDlgItem(IDC_EDIT3)->SetWindowText(key_jia);
key_cs=csdlg.key_cs;
UpdateData(1);
}
void CShiYan2Dlg::OnBnClickedBlA()
{
// TODO: Add your co