|
本帖最后由 shuren88 于 2013-5-1 17:26 编辑
花了两天时间,终于将Autoit的_StringEncrypt函数移植到VC6中,已经测试成功。确实有点苦。
当然,VC6中有许多现成的RC4加密解密程序和类。但是用Autoit的_StringEncrypt函数加密的密码字符串,一般都不能直接使用现成的VC6的RC4加密解密程序成功解密。所以一发狠心,发狠将Autoit的_StringEncrypt函数移植到VC6中。花了两天时间,终于成功了,用Autoit的_StringEncrypt函数加密的密码字符串已经能够在VC6中重现,也能够正确解密。大输了一口气,确实有点苦。
最苦的是,在调试Autoit的让人蛋痛的Asc函数,没有官方的资料说明Asc函数只能处理ASCII码小于128的字符数据,对ASCII码大于128的字符数据都一律返回0x3F(十进制数63),这花了半天时间才调试成功。最后,在VC中使用if判断,最终得以调试正确。
for (i_EncryptCountA = 0; i_EncryptCountA < minglen; i_EncryptCountA++)
{
i_EncryptCountC = (i_EncryptCountC + 1) % 256;
i_EncryptCountD = (i_EncryptCountD + (unsigned char)av_EncryptBox[i_EncryptCountC][0]) % 256;
i_EncryptCountE = (unsigned char)av_EncryptBox[((unsigned char)av_EncryptBox[i_EncryptCountC][0] + (unsigned char)av_EncryptBox[i_EncryptCountD][0]) % 256][0];
//因为Autoit中AscW(ChrW(250))必须用宽字符格式。Asc和Chr只是8位字符格式。只能显示128以下的
//为了与Autoit中的RC4加解密兼容,所以做如下处理
if ((unsigned char)s_EncryptText[i_EncryptCountA] < 128)
v_EncryptCipherBy = (unsigned char)s_EncryptText[i_EncryptCountA] ^ (unsigned char)i_EncryptCountE;
else
v_EncryptCipherBy = 63 ^ (unsigned char)i_EncryptCountE;
//$v_EncryptCipherBy = BitXOR(Asc(StringMid($s_EncryptText, $i_EncryptCountA, 1)), $i_EncryptCountE)
v_EncryptCipherR += char2Hex((unsigned char)v_EncryptCipherBy);
//*myDebugA = 0;
//sprintf(myDebugA, "%d,%d,%d,%d,%d\n", (unsigned char)i_EncryptCountC, (unsigned char)i_EncryptCountD, (unsigned char)i_EncryptCountE, (unsigned char)s_EncryptText[i_EncryptCountA],(unsigned char)v_EncryptCipherBy);
//OutputDebugString(myDebugA);
} |
|