-
Notifications
You must be signed in to change notification settings - Fork 9
/
cxcrc.h
60 lines (38 loc) · 1.72 KB
/
cxcrc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef CXCRC_H
#define CXCRC_H
#include "cxglobal.h"
class GM_CCXX_CORE_API CxCrc
{
public:
static uchar calcsum8(const uchar* pData, int iLength);
static ushort calcsum16(const uchar* pData, int iLength);
// check table style
static uchar calcCRC8(const uchar* pData, int iLength);
// check table style
static ushort calcCRC16(const uchar* pData, int iLength);
static short calcCRC16(const char* pData, int iLength);
//check table style
static ushort calcModbus(const uchar* pData, int iLength);
static std::string md5HexCode(const std::string& sData);
static std::string md5HexCode(const std::vector<std::string>& sLines);
static std::vector<char> md5(const std::vector<std::string>& sLines);
static std::vector<char> md5(const char* pData, int iLength);
/**
* @brief md5
* @param sFilePath
* @param iCodeType : 0=data ; 1=hex
* @return : empty=file is empty or error
*/
static std::string file2md5(const std::string &sFilePath, int iCodeType = 1);
static bool isSameMd5FileData(const std::string &sFilePath1, const std::string &sFilePath2);
static uchar calcXOR(const uchar* pData, int iLength);
// formula style
static uchar crc8(const uchar * ptr, int len);
static unsigned int calculate_crc16_2(unsigned char *ptr, unsigned char len);
// simple encrypt
static std::string encodeXorFix(const char* pData, int iDataLength, const char* pKey, int iKeyLength);
static std::string decodeXorFix(const char* pData, int iDataLength, const char* pKey, int iKeyLength);
static std::string encodeXorFix(const char* pData, int iLength);
static std::string decodeXorFix(const char* pData, int iLength);
};
#endif // CXCRC_H