国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C++ > 正文

VC++ 字符串String MD5計算小工具 VS2008工程

2020-01-26 14:00:28
字體:
供稿:網(wǎng)友

基于字符串加密的MD5算法,VS2008 VC++,多字節(jié)編譯工程。主要代碼如下,實現(xiàn)了ANSI字符串加密與Unicode字符串加密。

運(yùn)行效果如下:

核心代碼:

void CEncryptByMd5Dlg::OnButtonOk()  {   // TODO: Add your control notification handler code here   UpdateData(true);   unsigned int len=0;   char *cTemp =NULL;   if(m_bType==0)   {     len=m_sText.GetLength();     cTemp=(char*)(LPCTSTR)m_sText;   }   else   {     len=CStringW(m_sText).GetLength()*2;     cTemp=(char*)ANSI2UNICODE(m_sText);   }   char *cIdentity;   CMd5A md5;   cIdentity = md5.MDString(cTemp,len);   m_sEncrypt = CString(cIdentity);   if(m_bUpper==TRUE)   {     m_sEncrypt.MakeUpper();   }   else   {     m_sEncrypt.MakeLower();   }   UpdateData(false); }  void CEncryptByMd5Dlg::OnBnClickedBtnCompare() {   // TODO: Add your control notification handler code here   UpdateData(true);   if(m_sEncrypt==m_szMD5_2)   {     MessageBox(_T("密文比較結(jié)果相同!"),_T("比較相同"),MB_OK|MB_ICONINFORMATION);   }   else   {     MessageBox(_T("密文比較結(jié)果失敗!"),_T("比較不同"),MB_OK|MB_ICONERROR);   }   UpdateData(FALSE); }  void CEncryptByMd5Dlg::OnEnChangeEdit1() {   // TODO: If this is a RICHEDIT control, the control will not   // send this notification unless you override the CDialog::OnInitDialog()   // function and call CRichEditCtrl().SetEventMask()   // with the ENM_CHANGE flag ORed into the mask.   OnButtonOk();   // TODO: Add your control notification handler code here }  char * CEncryptByMd5Dlg::Unicode2ANSI(CString strSource) {   if (strSource.IsEmpty()) return NULL;   char *pBuffer = NULL;   int nBufferSize = 0; #ifdef _UNICODE    nBufferSize = WideCharToMultiByte(CP_ACP, 0, (LPCTSTR)strSource, -1, NULL, 0, NULL, NULL) + 1;   pBuffer = new char[nBufferSize];   memset(pBuffer, 0, sizeof(char)*nBufferSize);    WideCharToMultiByte(CP_ACP, 0, (LPCTSTR)strSource, -1, pBuffer, nBufferSize, NULL, NULL); #else    nBufferSize = strSource.GetLength() + 1;   pBuffer = new char[nBufferSize];   memset(pBuffer, 0, sizeof(char)*nBufferSize);    strcpy_s(pBuffer, nBufferSize, (LPCTSTR)strSource); #endif    return pBuffer; }  wchar_t * CEncryptByMd5Dlg::ANSI2UNICODE(CString pData) {   int nLength = MultiByteToWideChar(CP_ACP, 0, pData, -1, NULL, 0);   wchar_t *pwBuffer = new wchar_t[nLength + 1];   memset(pwBuffer, 0, sizeof(wchar_t)*(nLength + 1));   MultiByteToWideChar(CP_ACP, 0, pData, -1, pwBuffer, nLength);   return pwBuffer; }  void CEncryptByMd5Dlg::OnBnClickedCheckUpper() {   OnButtonOk();   // TODO: Add your control notification handler code here }  void CEncryptByMd5Dlg::OnBnClickedRadio1() {   OnButtonOk();   // TODO: Add your control notification handler code here }  void CEncryptByMd5Dlg::OnBnClickedRadio2() {   OnButtonOk();   // TODO: Add your control notification handler code here }

VS2008 MFC工程源碼下載:點擊打開鏈接

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 林甸县| 吴江市| 安宁市| 凭祥市| 东乡| 长春市| 沾化县| 定西市| 大渡口区| 洱源县| 漾濞| 育儿| 宁陵县| 滦南县| 桃园县| 潼关县| 澄城县| 龙江县| 本溪| 宁乡县| 阳城县| 甘泉县| 宜丰县| 裕民县| 咸宁市| 永泰县| 茶陵县| 德安县| 海林市| 吉木萨尔县| 吉安县| 普兰县| 沅江市| 大连市| 宜川县| 芮城县| 安泽县| 高淳县| 会宁县| 阿鲁科尔沁旗| 宜章县|