C/C++ 调用javascript加密WEBQQ密码

WEBQQ加密算法  C/C++调用javascript

顺便备用,以后贴上WEBQQ登陆的代码

[cpp]
CString Password(CString Uid,CString Pwd,CString v)
{
CString strRt;
LPSAFEARRAY psa;
SAFEARRAYBOUND rgsabound[] = { 3, 0 };
psa = SafeArrayCreate(VT_VARIANT, 1, rgsabound);
VARIANT vFlavors[3];
for (int i = 0; i < 3; i++)
{
VariantInit(&vFlavors[i]);
V_VT(&vFlavors[i]) = VT_BSTR;
}
CString sText = "text string";

V_BSTR(&vFlavors[0]) = SysAllocString(Uid.AllocSysString());//参数,账号
V_BSTR(&vFlavors[1]) = SysAllocString(Pwd.AllocSysString());//参数,密码
V_BSTR(&vFlavors[2]) = SysAllocString(v.AllocSysString());//参数,验证码
long lZero = 0;
long lOne = 1;
long lTwo = 2;
SafeArrayPutElement(psa, &lZero,&vFlavors[0]);
SafeArrayPutElement(psa, &lOne,&vFlavors[1]);
SafeArrayPutElement(psa, &lTwo,&vFlavors[2]);
for(int i=0;i<3;i++)
{
SysFreeString(vFlavors[i].bstrVal);
}

IScriptControlPtr pScriptControl(__uuidof(ScriptControl));
pScriptControl->Language = "JScript";
pScriptControl->AllowUI = TRUE;
string data=ReadFile("WEBQQJavaScript.txt");//读入javascript代码,我放在目录下了
pScriptControl->AddCode(data.c_str());
_variant_t outpar = pScriptControl->Run("Password", &psa);//调用Password方法,psa是参数
return outpar;//返回
}

strPwd=Password(strUid,strPwd,strVerify);//调用,返回加密后的密码
[/cpp]

ReadFile的代码

[cpp]
string ReadFile(string name)
{
string strRt;
HANDLE hFile=CreateFile(name.c_str(),GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
DWORD dwTmp;
while(true)
{
char buf[1025]={0};
ReadFile(hFile,buf,1024,&dwTmp,NULL);
if(dwTmp<=0)break;
strRt+=buf;
}
CloseHandle(hFile);
return strRt;
}
[/cpp]

点赞

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据