在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
// CPPdesTest.cpp : 定义控制台应用程序的入口点。 #include "stdafx.h" #include <stdio.h> std::string string_To_UTF8(const std::string & str) wchar_t * pwBuf = new wchar_t[nwLen + 1];//一定要加1,不然会出现尾巴 ::MultiByteToWideChar(CP_ACP, 0, str.c_str(), str.length(), pwBuf, nwLen); int nLen = ::WideCharToMultiByte(CP_UTF8, 0, pwBuf, -1, NULL, NULL, NULL, NULL); char * pBuf = new char[nLen + 1]; ::WideCharToMultiByte(CP_UTF8, 0, pwBuf, nwLen, pBuf, nLen, NULL, NULL); std::string retStr(pBuf); delete[]pwBuf; pwBuf = NULL; return retStr; // typedef struct LPSTR ConvertGBKToUtf8(LPSTR strGBK) len = WideCharToMultiByte(CP_UTF8, 0, wszUtf8, -1, NULL, 0, NULL, NULL); return szUtf8; void Base64Encode(BYTE *src, int src_len, BYTE *dst) int i = 0, j = 0; char base64_map[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; for (; i < src_len - src_len % 3; i += 3) { dst[j++] = base64_map[(src[i] >> 2) & 0x3F]; dst[j++] = base64_map[((src[i] << 4) & 0x30) + ((src[i + 1] >> 4) & 0xF)]; dst[j++] = base64_map[((src[i + 1] << 2) & 0x3C) + ((src[i + 2] >> 6) & 0x3)]; dst[j++] = base64_map[src[i + 2] & 0x3F]; } if (src_len % 3 == 1) { dst[j++] = base64_map[(src[i] >> 2) & 0x3F]; dst[j++] = base64_map[(src[i] << 4) & 0x30]; dst[j++] = '='; dst[j++] = '='; } dst[j++] = base64_map[(src[i] >> 2) & 0x3F]; dst[j++] = base64_map[((src[i] << 4) & 0x30) + ((src[i + 1] >> 4) & 0xF)]; dst[j++] = base64_map[(src[i + 1] << 2) & 0x3C]; dst[j++] = '='; } dst[j] = '\0'; } DWORD DesEncrypt(char* szEncrypt, char* szKey, BYTE* szOut, DWORD nOutLen) DWORD dwEncrypt = strlen(sz_utf8_buff); if (szOut == NULL || \ // HCRYPTPROV hProv = NULL; KeyBlob blob; BYTE IV[9] = { 0 }; // CryptAcquireContext(&hProv, NULL, MS_DEF_PROV, PROV_RSA_FULL, 0); // CryptEncrypt(hSessionKey, NULL, TRUE, 0, (BYTE*)szOut, &dwEncrypt, nOutLen); // CryptDestroyKey(hSessionKey); return dwEncrypt; char* Encrypt(char* sz_encrypt, char* sz_key) // DWORD dwRet = DesEncrypt(sz_encrypt, sz_key, szOut, 1024); // int nLen = strlen((char*)szOut); memset(szBase64, 0, nLenOut + 1); Base64Encode(szOut, nLen, szBase64); return (char*)szBase64;
strParameter = string_To_UTF8(strParameter); strRequest = Encrypt("currentpage=1&pagesize=1000000&starttime=1514736000&endtime=1514822399&paystatus=", "punr8ucu");
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论