C++加密 解密
我做一个C++加密,解密的问题,总是出现无法取到值的情况,怎么回事呢??
if(g_DBHelper.CheckInitFlagUsed(m_stCardBatch.szTypeId))
{
char pszOprNm1[25]={0};
char pszOprNm2[25]={0};
char pszOprPwd[25]={0};
char pszOprPwd1[25]={0};
g_DBHelper.SelOprID(pszOprNm1,pszOprNm2);
g_DBHelper.SelOprNm(pszOprPwd,pszOprPwd1);
CDialog Dlg(IDD_DIALOGBatchUser);
SetDlgItemText(IDC_STATICGeneral,pszOprNm1);
SetDlgItemText(IDC_STATICSpecial,pszOprNm2);
SetDlgItemText(IDC_EDIT_Password,pszOprPwd);
SetDlgItemText(IDC_EDIT_Password1,pszOprPwd1);
Dlg.DoModal();
CString strInPswd;
CString strRealPswd;
CString strGeneral;
CString strSpecial;
CString strUserID;
GetDlgItemText(IDC_COMBOPsw,strRealPswd);
GetDlgItemText(IDC_EDIT_Passwd,strInPswd);
GetDlgItemText(IDC_STATICGeneral,strGeneral);
GetDlgItemText(IDC_STATICSpecial,strSpecial);
GetDlgItemText(IDC_COMBOUserID,strUserID);
HINSTANCE hinstLib;
DBPwdEncryptP DBPwdEncrypt;
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
char szPswCiper[1024] = {0};
bool bTrueIsLoadOK = false;
hinstLib = LoadLibrary(TEXT("Issuecard.dll"));
if (hinstLib != NULL)
{
DBPwdEncrypt = (DBPwdEncryptP) GetProcAddress(hinstLib, TEXT("_DBPwdEncrypt@8"));
if (NULL != DBPwdEncrypt)
{
char szInPsw[1024] = {0};
strncpy(szInPsw, strInPswd.GetBuffer(0), sizeof(szInPsw));
try
{
DBPwdEncrypt(szInPsw, szPswCiper);
}
catch (...)
{
}
bTrueIsLoadOK = true;
}
fFreeResult = FreeLibrary(hinstLib);
}
if (!bTrueIsLoadOK)
{
MessageBox("解密模块加载失败。请与管理员联系");
CDialog::OnCancel();
return;
}
this->GetDlgItemText(IDC_STATICGeneral, g_SysPra.szOperName, sizeof(g_SysPra.szOperName));
this- GetDlgItemText(IDC_STATICSpecial, g_SysPra.szOperName, sizeof(g_SysPra.szOperName));
TirmString(g_SysPra.szOperName);
strncpy(g_SysPra.szOperID, strUserID.GetBuffer(0), sizeof(g_SysPra.szOperID));
strncpy(g_SysPra.szOperID, strUserID.GetBuffer(0), sizeof(g_SysPra.szOperID));
strncpy(g_SysPra.szSrcPswd, szPswCiper, sizeof(g_SysPra.szSrcPswd));
if (0 == strcmp(szPswCiper, strRealPswd.GetBuffer(0)))
{
CDialog::OnOK();
}
else
{
MessageBox("密码错误!");
this->SetDlgItemText(IDC_EDIT_Passwd, "");
return ;
}
CComboBox *pBoxUser = NULL;
pBoxUser = (CComboBox *)this->GetDlgItem(IDC_STATICGeneral);
CComboBox *pBoxUserID = NULL;
pBoxUserID = (CComboBox *)this->GetDlgItem(IDC_COMBOUserID);
CComboBox *pBoxUserPsw = NULL;
pBoxUserPsw = (CComboBox *)this->GetDlgItem(IDC_COMBOPsw);
pBoxUserID->SetCurSel(pBoxUser->GetCurSel());
pBoxUserPsw->SetCurSel(pBoxUser->GetCurSel());
}
总是出现取值取不到的情况。