34 lines
1.1 KiB
C++
34 lines
1.1 KiB
C++
#ifndef DSRCRYPTION_H
|
||
#define DSRCRYPTION_H
|
||
|
||
#define CRY_VERSION1 0x01
|
||
#define CRY_VERSION2 0x02
|
||
|
||
#define CUR_CRY_VERSION 0x01 // 当前的加密版本(取值范围为 0 -- 250),方便通过版本使用不同的加密方法。
|
||
#define BYTES_OF_CRY_FACTORS 32 // 加密因子字节数
|
||
|
||
|
||
class DsrCryption
|
||
{
|
||
public:
|
||
DsrCryption();
|
||
|
||
public:
|
||
int InitDsrCryptionCtrl(int version, unsigned int cryword, const unsigned char * factors); // 初始化加密控制, 自动生成生成加密字和加密因子
|
||
unsigned int GetDsrCryptionWord(); // 获取加密字
|
||
|
||
int EnCryption(unsigned char * pData, int size); // 加密数据,使用当前的加密字和加密因子
|
||
int DeCryption(unsigned char * pData, int size); // 解密数据,使用当前的加密字和加密因子
|
||
|
||
private:
|
||
int CreateCryWord(int version); // 生成加密字
|
||
int CreateCryFactors(const unsigned char * factors); // 生成加密因子
|
||
|
||
private:
|
||
int m_initflag;
|
||
unsigned int m_cryword;
|
||
unsigned char m_factors[BYTES_OF_CRY_FACTORS];
|
||
};
|
||
|
||
#endif // DSRCRYPTION_H
|