?? mixedcsdlg.cpp
字號:
if( ext.GetLength() )
m_output += "." + ext;
if( newext.GetLength() )
m_output += "." + newext;
UpdateData(false);
}
void CMixedCSDlg::OnOpen()
{
// TODO: Add your control notification handler code here
UpdateData(true);
if( run_type == ENCRYPT)
{
CHECK_MSG(CWindow::IsFileExist(m_input.GetBuffer(0)),"文件不存在! ")
ShellExecute(NULL,"open",m_input,NULL,NULL,SW_SHOWNORMAL);
}
else
{
CHECK_MSG(CWindow::IsFileExist(m_output.GetBuffer(0)),"文件不存在! ")
ShellExecute(NULL,"open",m_output,NULL,NULL,SW_SHOWNORMAL);
}
}
void CMixedCSDlg::OnRun()
{
// TODO: Add your control notification handler code here
CHECK( IDYES == MessageBox("真的要進(jìn)行該操作嗎? ","提示",MB_YESNO | MB_ICONQUESTION) )
bool flage;
DWORD time=GetTickCount();
// CString str= (run_type==ENCRYPT) ? "加密": "解密",tmp;
BuildOutputFileName();
if( format == DES )
CHECK_MSG( m_deskey == m_deskey2, "錯誤:DES密鑰不一致! " )
if( run_type==ENCRYPT)
{
if( format == MCS )
flage = mcs.Encrypt(m_output.GetBuffer(0),m_input.GetBuffer(0),
m_rsakey.GetBuffer(0),m_rsamod.GetBuffer(0),use3des);
else
flage = des.Encrypt(m_output.GetBuffer(0),m_input.GetBuffer(0),
m_deskey.GetBuffer(0));
}
else
{
if( format == MCS )
flage = mcs.Decrypt(m_output.GetBuffer(0),m_input.GetBuffer(0),
m_rsakey.GetBuffer(0),m_rsamod.GetBuffer(0));
else
flage = des.Decrypt(m_output.GetBuffer(0),m_input.GetBuffer(0),
m_deskey.GetBuffer(0));
}
if( flage )
{
Str.Format("%s成功! 用時%u秒。",(run_type==ENCRYPT)?"加密":"解密",(GetTickCount()-time)/1000);
MessageBox(Str,"提示",MB_ICONINFORMATION);
if( (run_type==ENCRYPT && delorgfile) ||
(run_type==DECRYPT && deleptfile) )
{
Str.Format("是否刪除文件:\n%s",m_input);
if( !delnote )
DeleteFile(m_input);
else if( IDYES==MessageBox(Str,"提示",MB_YESNO | MB_ICONQUESTION) )
DeleteFile(m_input);
}
}
}
void CMixedCSDlg::OnInputRsaKey()
{
// TODO: Add your control notification handler code here
UpdateData(true);
theApp.InputKeyStr(m_rsakey);
Str.Format("RSA密鑰(%d)",m_rsakey.GetLength());
SetDlgItemText(IDC_RSASTATICKEY,Str);
UpdateData(false);
}
void CMixedCSDlg::OnInputRsaMod()
{
// TODO: Add your control notification handler code here
UpdateData(true);
theApp.InputKeyStr(m_rsamod);
Str.Format("RSA模n (%d)",m_rsamod.GetLength());
SetDlgItemText(IDC_RSASTATICMOD,Str);
UpdateData(false);
}
void CMixedCSDlg::OnChangeRsaKey()
{
// TODO: Add your control notification handler code here
UpdateData(true);
theApp.CheckKeyStr(m_rsakey);
Str.Format("RSA密鑰(%d)",m_rsakey.GetLength());
SetDlgItemText(IDC_RSASTATICKEY,Str);
UpdateData(false);
}
void CMixedCSDlg::OnChangeRsaMod()
{
// TODO: Add your control notification handler code here
UpdateData(true);
theApp.CheckKeyStr(m_rsamod);
Str.Format("RSA模n (%d)",m_rsamod.GetLength());
SetDlgItemText(IDC_RSASTATICMOD,Str);
UpdateData(false);
}
void CMixedCSDlg::OnMcsradio()
{
// TODO: Add your control notification handler code here
oldformat = format = MCS;
if( run_type==ENCRYPT )
BuildOutputFileName();
EnableMcsCtls(true);
EnableDesCtls(false);
}
void CMixedCSDlg::OnDesradio()
{
// TODO: Add your control notification handler code here
oldformat = format = DES;
if( run_type==ENCRYPT )
BuildOutputFileName();
EnableDesCtls(true);
EnableMcsCtls(false);
}
void CMixedCSDlg::OnGetRsaKey()
{
// TODO: Add your control notification handler code here
CRsaKeyDlg rsakey;
rsakey.DoModal();
}
void CMixedCSDlg::OnDefFolder()
{
// TODO: Add your control notification handler code here
UpdateData(true);
CWindow::GetFolder(m_defpath);
UpdateData(false);
BuildOutputFileName();
}
void CMixedCSDlg::OnOutFolder()
{
// TODO: Add your control notification handler code here
CString defpath = m_defpath;
bool tmp = usedefpath;
usedefpath = true;
UpdateData(true);
CWindow::GetFolder(m_defpath);
UpdateData(false);
BuildOutputFileName();
m_defpath = defpath;
usedefpath = tmp;
UpdateData(false);
}
void CMixedCSDlg::OnDefPathCHECK()
{
// TODO: Add your control notification handler code here
usedefpath = !usedefpath;
if( usedefpath )
{
EnableDefPathCtls(true);
BuildOutputFileName();
}
else
{
EnableDefPathCtls(false);
}
}
void CMixedCSDlg::OnUse3DESCHECK()
{
// TODO: Add your control notification handler code here
use3des = !use3des;
}
void CMixedCSDlg::OnDelEptFileCHECK()
{
// TODO: Add your control notification handler code here
deleptfile = !deleptfile;
}
void CMixedCSDlg::OnDelOrgFileCHECK()
{
// TODO: Add your control notification handler code here
delorgfile = !delorgfile;
}
void CMixedCSDlg::OnDelNoteCHECK()
{
// TODO: Add your control notification handler code here
delnote = !delnote;
}
void CMixedCSDlg::EnableDesCtls(bool show)
{
if(show)
{
GetDlgItem(IDC_DESSTATIC)->EnableWindow(true);
GetDlgItem(IDC_DESSTATICKEY)->EnableWindow(true);
GetDlgItem(IDC_DESSTATICKEY2)->EnableWindow(true);
GetDlgItem(IDC_DESSTATICNOTE)->EnableWindow(true);
GetDlgItem(IDC_DesKey)->EnableWindow(true);
GetDlgItem(IDC_DesKey2)->EnableWindow(true);
}
else
{
GetDlgItem(IDC_DESSTATIC)->EnableWindow(false);
GetDlgItem(IDC_DESSTATICKEY)->EnableWindow(false);
GetDlgItem(IDC_DESSTATICKEY2)->EnableWindow(false);
GetDlgItem(IDC_DESSTATICNOTE)->EnableWindow(false);
GetDlgItem(IDC_DesKey)->EnableWindow(false);
GetDlgItem(IDC_DesKey2)->EnableWindow(false);
}
}
void CMixedCSDlg::EnableMcsCtls(bool show)
{
if(show)
{
GetDlgItem(IDC_MCSSTATIC)->EnableWindow(true);
GetDlgItem(IDC_RSASTATICKEY)->EnableWindow(true);
GetDlgItem(IDC_RSASTATICMOD)->EnableWindow(true);
GetDlgItem(IDC_RsaKey)->EnableWindow(true);
GetDlgItem(IDC_RsaMod)->EnableWindow(true);
GetDlgItem(IDC_InputRsaKey)->EnableWindow(true);
GetDlgItem(IDC_InputRsaMod)->EnableWindow(true);
GetDlgItem(IDC_Use3DESCHECK)->EnableWindow(true);
}
else
{
GetDlgItem(IDC_MCSSTATIC)->EnableWindow(false);
GetDlgItem(IDC_RSASTATICKEY)->EnableWindow(false);
GetDlgItem(IDC_RSASTATICMOD)->EnableWindow(false);
GetDlgItem(IDC_RsaKey)->EnableWindow(false);
GetDlgItem(IDC_RsaMod)->EnableWindow(false);
GetDlgItem(IDC_InputRsaKey)->EnableWindow(false);
GetDlgItem(IDC_InputRsaMod)->EnableWindow(false);
GetDlgItem(IDC_Use3DESCHECK)->EnableWindow(false);
}
}
void CMixedCSDlg::EnableDefPathCtls(bool show)
{
if(show)
{
GetDlgItem(IDC_DEFPATHSTATIC)->EnableWindow(true);
GetDlgItem(IDC_DefPath)->EnableWindow(true);
GetDlgItem(IDC_DefFolder)->EnableWindow(true);
}
else
{
GetDlgItem(IDC_DEFPATHSTATIC)->EnableWindow(false);
GetDlgItem(IDC_DefPath)->EnableWindow(false);
GetDlgItem(IDC_DefFolder)->EnableWindow(false);
}
}
void CMixedCSDlg::EnableFormatCtls(bool show)
{
CButton *mcscheck=(CButton*)GetDlgItem(IDC_MCSRADIO),
*descheck=(CButton*)GetDlgItem(IDC_DESRADIO);
if( show )
{
GetDlgItem(IDC_FORMATSTATIC)->EnableWindow(true);
GetDlgItem(IDC_FMTSTATICFRM)->EnableWindow(true);
descheck->EnableWindow(true);
mcscheck->EnableWindow(true);
}
else
{
GetDlgItem(IDC_FORMATSTATIC)->EnableWindow(false);
GetDlgItem(IDC_FMTSTATICFRM)->EnableWindow(false);
descheck->EnableWindow(false);
mcscheck->EnableWindow(false);
}
}
void CMixedCSDlg::OnAbout()
{
// TODO: Add your control notification handler code here
CAboutDlg dlg;
dlg.DoModal();
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -