⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ccrc32.cpp

📁 PGP8.0源码 请认真阅读您的文件包然后写出其具体功能
💻 CPP
字号:
/*____________________________________________________________________________
		Copyright (C) 2002 PGP Corporation
        All rights reserved.

        $Id: CCRC32.cpp,v 1.2 2002/08/06 20:10:18 dallen Exp $
____________________________________________________________________________*/

#include "pgpClassesConfig.h"
#include "CCRC32.h"

_USING_PGP

// Class CCRC32 member functions

CCRC32::CCRC32()
{
	Init();
}

void 
CCRC32::Init(PGPUInt32 startCRC)
{
	mCurrentCRC = startCRC;
}

void
CCRC32::Continue(const PGPUInt32 *theDWords, PGPUInt32 nDWords)
{
	PGPUInt32		k4C11DB7	= 0x04C11DB7;
	PGPUInt32 const	*curDWord 	= theDWords;
	PGPUInt32 const	*lastDWord	= theDWords + (nDWords - 1);

	while (curDWord <= lastDWord )
	{
		PGPUInt8		bytes[4];
		const PGPUInt8	*curByte;
		PGPInt32		remaining;
		PGPUInt32		theDWord;
		
		// We want an endian-independent CRC - place the bytes in big-endian
		// order.

		theDWord = (* curDWord++);

		bytes[0]	= (PGPUInt8) (theDWord >> 24) & 0xFF;
		bytes[1]	= (PGPUInt8) (theDWord >> 16) & 0xFF;
		bytes[2]	= (PGPUInt8) (theDWord >> 8) & 0xFF;
		bytes[3]	= (PGPUInt8) theDWord & 0xFF;
		
		remaining = 4;
		curByte = bytes;

		while (remaining-- != 0)
		{
			PGPInt32 check;

			mCurrentCRC ^= ((PGPInt32 ) (* curByte)) << 8;
			++curByte;

			for (PGPUInt8 i = 0; i < 8; i++)
			{
				check = mCurrentCRC;
				mCurrentCRC <<= 1;

				if (check < 0)
					mCurrentCRC ^= k4C11DB7;
			}
		}
	}
}

⌨️ 快捷键说明

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