冬
冬月
Unregistered / Unconfirmed
GUEST, unregistred user!
int L1PacketCore::Initial(DWORD skey)
{
BYTE key[8];
DWORD *pdata=(DWORD *)key;
pdata[0]=skey;
pdata[1]=0x930fd7e2;
blowFish.Initialize(key,8);
DWORD *pKey=(DWORD *)m_SSendKey;
pKey[0]=pdata[0];
pKey[1]=pdata[1];
pKey=(DWORD *)m_SRecvKey;
pKey[0]=pdata[0];
pKey[1]=pdata[1];
pKey=(DWORD *)m_CSendKey;
pKey[0]=pdata[0];
pKey[1]=pdata[1];
pKey=(DWORD *)m_CRecvKey;
pKey[0]=pdata[0];
pKey[1]=pdata[1];
return 1;
}
void L1PacketCore::EnCode(BYTE* Sdata, int len, BYTE* key)
{
Sdata[0] = Sdata[0]^key[0];
for(int i = 1;i<len;i++)
Sdata = Sdata^ Sdata[i-1] ^ key[i&7];
Sdata[3] = Sdata[3]^key[2];
Sdata[2] = Sdata[2]^Sdata[3]^key[3];
Sdata[1] = Sdata[1]^Sdata[2]^key[4];
Sdata[0] = Sdata[0]^Sdata[1]^key[5];
}
void L1PacketCore::UnCode(BYTE* Sdata, int len, BYTE* key)
{
int count=len-1;
Sdata[0] = Sdata[0]^Sdata[1]^key[5];
Sdata[1] = Sdata[1]^Sdata[2]^key[4];
Sdata[2] = Sdata[2]^Sdata[3]^key[3];
Sdata[3] = Sdata[3]^key[2];
for(int i = count;i>0;i--)
Sdata = Sdata^ Sdata[i-1] ^ key[i&7];
Sdata[0] = Sdata[0]^key[0];
}
int L1PacketCore::OnUnS2C(BYTE* SData, int len)
{
UnCode(SData,len,m_CRecvKey);
DWORD *pData=(DWORD *)SData;
DWORD *pKey=(DWORD *)m_CRecvKey;
pKey[0]^=*pData;
pKey[1]+=0x287EFFC3;
EnCode(SData,len,m_SSendKey);
pKey=(DWORD *)m_SSendKey;
pKey[0]^=*pData;
pKey[1]+=0x287EFFC3;
return 0;
}
int L1PacketCore::OnUnC2S(BYTE* SData, int len)
{
UnCode(SData,len,m_SRecvKey);
DWORD *pData=(DWORD *)SData;
DWORD *pKey=(DWORD *)m_SRecvKey;
pKey[0]^=*pData;
pKey[1]+=0x287EFFC3;
EnCode(SData,len,m_CSendKey);
pKey=(DWORD *)m_CSendKey;
pKey[0]^=*pData;
pKey[1]+=0x287EFFC3;
return 0;
}
{
BYTE key[8];
DWORD *pdata=(DWORD *)key;
pdata[0]=skey;
pdata[1]=0x930fd7e2;
blowFish.Initialize(key,8);
DWORD *pKey=(DWORD *)m_SSendKey;
pKey[0]=pdata[0];
pKey[1]=pdata[1];
pKey=(DWORD *)m_SRecvKey;
pKey[0]=pdata[0];
pKey[1]=pdata[1];
pKey=(DWORD *)m_CSendKey;
pKey[0]=pdata[0];
pKey[1]=pdata[1];
pKey=(DWORD *)m_CRecvKey;
pKey[0]=pdata[0];
pKey[1]=pdata[1];
return 1;
}
void L1PacketCore::EnCode(BYTE* Sdata, int len, BYTE* key)
{
Sdata[0] = Sdata[0]^key[0];
for(int i = 1;i<len;i++)
Sdata = Sdata^ Sdata[i-1] ^ key[i&7];
Sdata[3] = Sdata[3]^key[2];
Sdata[2] = Sdata[2]^Sdata[3]^key[3];
Sdata[1] = Sdata[1]^Sdata[2]^key[4];
Sdata[0] = Sdata[0]^Sdata[1]^key[5];
}
void L1PacketCore::UnCode(BYTE* Sdata, int len, BYTE* key)
{
int count=len-1;
Sdata[0] = Sdata[0]^Sdata[1]^key[5];
Sdata[1] = Sdata[1]^Sdata[2]^key[4];
Sdata[2] = Sdata[2]^Sdata[3]^key[3];
Sdata[3] = Sdata[3]^key[2];
for(int i = count;i>0;i--)
Sdata = Sdata^ Sdata[i-1] ^ key[i&7];
Sdata[0] = Sdata[0]^key[0];
}
int L1PacketCore::OnUnS2C(BYTE* SData, int len)
{
UnCode(SData,len,m_CRecvKey);
DWORD *pData=(DWORD *)SData;
DWORD *pKey=(DWORD *)m_CRecvKey;
pKey[0]^=*pData;
pKey[1]+=0x287EFFC3;
EnCode(SData,len,m_SSendKey);
pKey=(DWORD *)m_SSendKey;
pKey[0]^=*pData;
pKey[1]+=0x287EFFC3;
return 0;
}
int L1PacketCore::OnUnC2S(BYTE* SData, int len)
{
UnCode(SData,len,m_SRecvKey);
DWORD *pData=(DWORD *)SData;
DWORD *pKey=(DWORD *)m_SRecvKey;
pKey[0]^=*pData;
pKey[1]+=0x287EFFC3;
EnCode(SData,len,m_CSendKey);
pKey=(DWORD *)m_CSendKey;
pKey[0]^=*pData;
pKey[1]+=0x287EFFC3;
return 0;
}