42 lines
820 B
C
42 lines
820 B
C
|
|
|
|||
|
|
#pragma once
|
|||
|
|
#include "DNPacket.h"
|
|||
|
|
#include "MtRandom.h"
|
|||
|
|
|
|||
|
|
// 2009.01.19 <20><><EFBFBD><EFBFBD>
|
|||
|
|
// DNGAME_PACKET <20>ش<EFBFBD> ũ<><C5A9> <20><><EFBFBD><EFBFBD>
|
|||
|
|
const int DNGAME_PACKET_HEADERSIZE = 7;
|
|||
|
|
|
|||
|
|
class CCryptoPacket
|
|||
|
|
{
|
|||
|
|
public:
|
|||
|
|
CCryptoPacket();
|
|||
|
|
virtual ~CCryptoPacket() {}
|
|||
|
|
|
|||
|
|
int EncodeGamePacket(void *p, int main_header, int sub_header, const void *message, int size, BYTE cSeq = 0);
|
|||
|
|
bool DecodeGamePacket(DNGAME_PACKET *p);
|
|||
|
|
int CalcGamePacketSize(void *p, int len); // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> -1 (<28><> <20><> <20><><EFBFBD><EFBFBD>)
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
class CCryptoKey
|
|||
|
|
{
|
|||
|
|
public:
|
|||
|
|
CCryptoKey();
|
|||
|
|
~CCryptoKey() {}
|
|||
|
|
|
|||
|
|
//for server
|
|||
|
|
bool ServerMakeKey(char * pKey, bool bCheck);
|
|||
|
|
int ServerVerifyKey(char * pKey);
|
|||
|
|
|
|||
|
|
//for client
|
|||
|
|
bool ClientVerifyKey(char * pKey);
|
|||
|
|
|
|||
|
|
private:
|
|||
|
|
CMtRandom m_Random;
|
|||
|
|
bool m_bMakeKey;
|
|||
|
|
|
|||
|
|
bool MakeCryptoKey(char * pBuf);
|
|||
|
|
int VerifyCryptoKey(char * pBuf, bool bFullLenth);
|
|||
|
|
};
|
|||
|
|
|