1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #include "stdafx.h"
- #include "MD5Test.h"
- #include "../lyfzClassicSvc/MD5.h"
- #include "StringProcess.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- CWinApp theApp;
- using namespace std;
- int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
- {
- int nRetCode = 0;
-
- if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
- {
-
- _tprintf(_T("错误: MFC 初始化失败\n"));
- nRetCode = 1;
- }
- else
- {
-
-
- CONST TCHAR* pMD5 = NULL;
-
- CMD5 md5((const BYTE*)("1234"), strlen("1234"));
- pMD5 = md5.GetMD5Digest();
- _tprintf(_T("%s\n"), pMD5);
-
- CHAR szUtf8[MAX_PATH] = {0};
- CHAR szbuffer[MAX_PATH] = "订单号:1779603670";
- StringProcess::ascii_to_utf8(szbuffer,szUtf8);
- md5.SetBYTEText(reinterpret_cast<BYTE*>(szUtf8), strlen(szUtf8));
- pMD5 = md5.GetMD5Digest();
- _tprintf(_T("%s\n"), pMD5);
-
- WCHAR szUnicode[MAX_PATH] = L"订单号:1779603670";
- BYTE szUN[MAX_PATH] = {0};
- INT nBytes = sizeof(WCHAR)*wcslen(szUnicode);
- memcpy(szUN, szUnicode, nBytes);
-
- md5.SetBYTEText(reinterpret_cast<BYTE*>(szUN), nBytes);
- pMD5 = md5.GetMD5Digest();
- _tprintf(_T("%s\n"), pMD5);
-
- CHAR szAscii[MAX_PATH] = {0};
- StringProcess::utf8_to_ascii(szUtf8,szAscii);
- md5.SetBYTEText(reinterpret_cast<BYTE*>(szAscii), strlen(szAscii));
- pMD5 = md5.GetMD5Digest();
- _tprintf(_T("%s\n"), pMD5);
- }
- system("pause");
- return nRetCode;
- }
|