C++加密 解密

qingshe3 2012-05-28 02:17:21
我做一个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());
}
总是出现取值取不到的情况。
...全文
145 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
我不懂电脑 2012-05-29
  • 打赏
  • 举报
回复
设置断点,单步调试。看问题出在哪个函数,哪条语句。
qingshe3 2012-05-29
  • 打赏
  • 举报
回复
就是从CString开始无法取值的,就是取数据库里面的用户想对应的密码
dataxdata 2012-05-28
  • 打赏
  • 举报
回复
取不到什么值?

13,826

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧