In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the example analysis of MD5 algorithm based on string encryption, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.
MD5 algorithm based on string encryption, VS2008 VC++, multibyte compilation project. The main code is as follows, to achieve the ANSI string encryption and Unicode string encryption.
The running effect is as follows:
Core code:
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) missus text;} 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 ("same ciphertext comparison result!), _ T (" compare the same result "), MB_OK | MB_ICONINFORMATION);} else {MessageBox (_ T (" ciphertext comparison result failed! ") , _ T ("compare different"), 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} Thank you for reading this article carefully. I hope the article "sample Analysis of MD5 algorithm based on string encryption" shared by the editor will be helpful to you. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.