DES加密算法实现论文 联系客服

发布时间 : 星期二 文章DES加密算法实现论文更新完毕开始阅读01262b3887c24028915fc3a3

}

void CTJUT_DES_TOOLDlg::OnRadioFile() {

// TODO: Add your control notification handler code here Fromwhich=FROMFILE;

myeditfile.EnableWindow(TRUE); myeditchar.EnableWindow(FALSE); myedithex.EnableWindow(FALSE); myopenfile.EnableWindow(TRUE); }

void CTJUT_DES_TOOLDlg::OnRadioHex() {

// TODO: Add your control notification handler code here Fromwhich=FROMHEX;

myeditfile.EnableWindow(FALSE); myeditchar.EnableWindow(FALSE); myedithex.EnableWindow(TRUE); myopenfile.EnableWindow(FALSE); }

void CTJUT_DES_TOOLDlg::OnCancel() {

// TODO: Add extra cleanup here

CDialog::OnCancel(); }

void CTJUT_DES_TOOLDlg::OnOK() {

// TODO: Add extra validation here

//CDialog::OnOK(); return; }

void CTJUT_DES_TOOLDlg::OnButtonCompute1() {

// TODO: Add your control notification handler code here CString oStr,oStrpwd,oStrpwdc; int iLen;

unsigned char pt[8];//=static_cast(_alloca(iLen));

myeditpwd.GetWindowText(oStrpwd); myeditpwdc.GetWindowText(oStrpwdc); if(oStrpwd.Compare(LPCTSTR(oStrpwdc))) { myeditresult.SetWindowText(\密钥设置不一致!请重新设置。\ return; }

if(oStrpwd.GetLength()!=16) { myeditresult.SetWindowText(\密钥长度不对!请重新设置。\ return; }

iLen = oStrpwd.GetLength()/2;

char* pcDatapwd = static_cast(_alloca(iLen));

Hex2Binary(LPCTSTR(oStrpwd), reinterpret_cast(pcDatapwd), iLen); oDES.setkey(reinterpret_cast(pcDatapwd));

switch(Fromwhich) {

case FROMCHAR: { myeditchar.GetWindowText(oStr); if(oStr.GetLength()!=8) { myeditresult.SetWindowText(\密文长度不对!请重新输入。\ return; } char* pcData = static_cast(_alloca(8)); memcpy(pcData,LPCTSTR(oStr),8); oDES.dectransform(reinterpret_cast(pcData), pt); //Display the result char acHex[129] = {0}; Binary2Hex(reinterpret_cast(pt), 8, acHex); myeditresult.SetWindowText(acHex); break; }

case FROMHEX: { myedithex.GetWindowText(oStr); if(oStr.GetLength()!=16) { myeditresult.SetWindowText(\密文长度不对!请重新输入。\ return;

} iLen = oStr.GetLength()/2; char* pcData = static_cast(_alloca(iLen)); Hex2Binary(LPCTSTR(oStr), reinterpret_cast(pcData), iLen); oDES.dectransform(reinterpret_cast(pcData), pt); //Display the result char acHex[129] = {0}; Binary2Hex(reinterpret_cast(pt), 8, acHex); myeditresult.SetWindowText(acHex); break; }

case FROMFILE: { CString oStrFile; myeditfile.GetWindowText(oStrFile); if (oStrFile.IsEmpty()) { myeditfile.SetWindowText(\请输入文件名!\ myeditresult.SetWindowText(\ return; } try { CString oStrFile1; oStrFile1=oStrFile+\ oDES.decfile(oStrFile,oStrFile1); myeditresult.SetWindowText(LPCTSTR(oStrFile=\解密后的文件是:\ } catch(exception const& roException) { MessageBox(CString(roException.what()), g_oStrError, MB_OK|MB_ICONERROR); return; } break; } } }