#include "stdafx.h"
#include "XCrypt.h"
#define x_Password "1.0.0.0"
wstring ConvertMultiByteToWideChar(const std::string &input)
{
DWORD dwSize = MultiByteToWideChar(CP_ACP, 0, input.c_str(), -1, NULL, 0);
wchar_t * pBuffer = new wchar_t[dwSize];
MultiByteToWideChar(CP_ACP, 0, input.c_str(), -1, pBuffer, dwSize);
wstring ouput(pBuffer);
delete[] pBuffer;
return ouput;
}
wstring Decrypt(LPCSTR lpszInput)
{
Xstring crypt(x_Password);
std::string output;
if(!crypt.DecryptString(lpszInput, output))
return L"";
return ConvertMultiByteToWideChar(output);
}
int main(int argc, wchar_t* argv[])
{
/*
加密后----------------加密前
"EeCpOoClBpPgFkFnBnCfFdPlBfOkIl" //WMOptimizer.txt
"HaFiPnAdEgMnFcEhAoCeEeLlBfLmJdFfPn" //c:\X-Resident.log
"ElEpPdDoBiPgFdFbAjDeAmJmApObIlFlPgPhHiDb" //X-Resident-Installer
"ElEpPdDoBiPgFdFbAjDe" //X-Resident
"EeAlMpDpAeOiEeBeCkCfEfLmAaLcLaEkOoPcHaCkFcNlHk";//Windows Media Optimizer
*/
string de="EeAlMpDpAeOiEeBeCkCfEfLmAaLcLaEkOoPcHaCkFcNlHk";//Windows Media Optimizer
cout<<de<<endl<<"length:"<<de.size()<<endl;
wstring out=Decrypt(de.c_str());
wcout<<out<<endl<<"length:"<<out.size()<<endl;
system("pause");
}
/*主要解密码函数如下:
BOOL Xstring::DecryptString(const std::string& input, std::string& output)
{
output = "";
if(!m_bSucceed || input.length() % 2 != 0) return false;
DWORD dwSize = input.length();
BYTE* lpTemp = new BYTE[dwSize];
memcpy_s(lpTemp, dwSize, input.c_str(), dwSize);
for(DWORD i=0; i<dwSize; i+=2)
lpTemp[i/2] = ((lpTemp[i] - 'A') << 4) | (lpTemp[i + 1] - 'a');
lpTemp[dwSize /= 2] = '\0';
BOOL bSucceed = ::CryptDecrypt(m_hKey, NULL, TRUE, 0, lpTemp, &dwSize);
if(bSucceed)
output = (char*)lpTemp;
delete[] lpTemp;
return bSucceed;
}
*/
求加密码函数
全部源码在附件
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!