能力值:
( LV2,RANK:10 )
8 楼
unsigned char arrSrc[] =
{
0x68, 0x72, 0x6E, 0xE1, 0xBA, 0x98, 0x21, 0x72, 0x96, 0x68, 0x1F,
0x0B, 0xDF, 0x97, 0x69, 0x8D, 0x87, 0x56, 0x38, 0x23, 0xEC, 0x66,
0xAD, 0x8D, 0x78, 0x82, 0x6C, 0xA6, 0x7D, 0xA5, 0x38, 0xC8, 0x4B,
0xEC, 0x69, 0x0D, 0x90, 0x40, 0x8C, 0xD5, 0x3F, 0xD4, 0x49, 0x01,
0x16, 0xA3, 0xF2, 0x73, 0xD1, 0x25, 0x56, 0x70, 0x4B, 0x5F, 0x9C,
0xDE, 0xA2, 0x7A, 0x99, 0xAA, 0x4B, 0x23, 0x6E, 0xC1, 0x46, 0x49,
0xC8, 0x2F, 0xA3, 0xF8, 0x2A, 0xDE, 0xF1, 0x82, 0x9F, 0xD8, 0x82,
0x3E, 0xFA
};
unsigned char arrDst[sizeof(arrSrc)];
/*
函数名: Decrypt
[参数]
chClearData : 输出缓冲区,接收解密成明文的数据;
chCipherDta : 输入缓冲区,接受待解密的密文数据;
count : 密文长度;
[返回值]
返回明文数据的缓冲区地址;
*/
unsigned char* Decrypt(unsigned char* chClearData, unsigned char* chCipherData, size_t count, unsigned short uKey)
{
for (size_t i = 0; i < count; ++i)
{
chClearData[i] = chCipherData[i] ^ uKey >> 8;
uKey = (chClearData[i] + uKey) * 0xA761 + 0x87B3;
}
return chClearData;
}
//解不出来,上面是我的代码,楼主知道哪里出问题了一定要记得告诉我啊。
能力值:
( LV2,RANK:10 )
9 楼
[QUOTE=gs笨笨;1403691]unsigned char arrSrc[] =
{
0x68, 0x72, 0x6E, 0xE1, 0xBA, 0x98, 0x21, 0x72, 0x96, 0x68, 0x1F,
0x0B, 0xDF, 0x97, 0x69, 0x8D, 0x87, 0x56, 0x38, 0x23, 0...[/QUOTE]
不好意思,刚调试了下,你说的不能解密是最后部分不能解密,少了一个判断,完整的解密是这样的
unsigned short uKey=0x27;
for (size_t i = 0; i < m_unencrypte.GetLength()/2; i++)
{
nHex[i] = nHexOut[i] ^uKey >> 8 ;
if(nHex[i]==0x0)
{
nHex[i]='/';
uKey = uKey * 0xA761 + 0x87B3;
}
else
{
uKey = (nHexOut[i] + uKey) * 0xA761 + 0x87B3;
}
}
非常感谢,但是又碰到问题了,该如何加密呢?乘法好像没有逆运算的
能力值:
( LV2,RANK:10 )
10 楼
[QUOTE=heihu;1403696]不好意思,刚调试了下,你说的不能解密是最后部分不能解密,少了一个判断,完整的解密是这样的
unsigned short uKey=0x27;
for (size_t i = 0; i < m_unencrypte.GetLength()/2; i++)
{
nHex[i] = ...[/QUOTE]
异或加解密都是需要同一个key,并不需要什么乘法逆运算,只需要把明文当作key来重新异或就行了