crc.h

来自「C++ patterns设计模式」· C头文件 代码 · 共 44 行

H
44
字号
#ifndef INCLUDED_CRC
#define INCLUDED_CRC

#if defined(HAS_PRAGMA_ONCE)
#pragma PRAGMA_ONCE_DECLARE
#endif

#ifdef NO_PRECOMPILE_HEADER
#include <string>
#endif

namespace stk
{
	typedef unsigned char  u8;
	typedef unsigned short u16;
	typedef unsigned int   u32;
	
	class CRCITU
	{
	public:
		// CRC16
		static u16 calc(const u8 *processData, size_t dataLength);
		static u16 calc(const std::string &data)
		{
			return calc((const u8 *)data.c_str(), data.length());
		}
		static u16 s_CRC16Table[];
	};

	class CRC32
	{
	public:
		//CRC32
		static u32 calc(const u8 *processData, size_t dataLength);
		static u32 calc(const std::string &data)
		{
			return calc((const u8 *)data.c_str(), data.length());
		}
		static u32 s_CRC32Table[];
	};
}

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?