QuiltingHMI/datafile/dsrcryption.h
2024-02-06 15:10:48 +08:00

34 lines
1.1 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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