当前位置: 首页>>代码示例>>C++>>正文


C++ CHash::Final方法代码示例

本文整理汇总了C++中CHash::Final方法的典型用法代码示例。如果您正苦于以下问题:C++ CHash::Final方法的具体用法?C++ CHash::Final怎么用?C++ CHash::Final使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CHash的用法示例。


在下文中一共展示了CHash::Final方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: doTestStepL


//.........这里部分代码省略.........
						TBool hashCopied = EFalse;
						TPtrC8 hashStr;
						
						CHash* hashCopyImpl = NULL;
						
						User::LeaveIfError(sourceFile.Size(sourceLength));
						
						//Divide the total size of the source file up into individual equal sized blocks to read
						//over several increments
						readIncrement = sourceLength/KDataReadBlocks;
						
						do 
							{							
							//Create a heap based descriptor to store the data
							HBufC8* sourceData = HBufC8::NewL(readIncrement);
							CleanupStack::PushL(sourceData);
							TPtr8 sourcePtr = sourceData->Des();
							
							//Read in a block of data from the source file from the current position
							err = sourceFile.Read(readPosition,sourcePtr,readIncrement);
							
							//Update the read position by adding the number of bytes read
							readPosition += readIncrement;
							
							if(readPosition == readIncrement)
								{
								//Read in the first block from the data file into the Hash implementation object
								hashImpl->Hash(*sourceData);
								INFO_PRINTF2(_L("Intial Hash - Bytes Read: %d"), readPosition);
								}
							else if(readPosition >= sourceLength)
								{
								//Reading in the final block, constructs the complete hash value and returns it within a TPtrC8
								hashStr.Set(hashCopyImpl->Final(*sourceData));
								
								//Sets the Complete Flag to ETrue in order to drop out of the loop
								hashComplete = ETrue;
								
								TInt totalRead = (readPosition - readIncrement) + (*sourceData).Length();
								INFO_PRINTF2(_L("Final Hash - Bytes Read: %d"),totalRead);
								}
							//If the read position is half the source length and the implementation
							//object hasn't already been copied
							else if((readPosition >= sourceLength/2) && (hashCopied == EFalse))
								{
								//Update the hash message before copying
								hashImpl->Update(*sourceData);
								
								INFO_PRINTF1(_L("Copying Hash Object..."));
								
								//Create a Copy of the existing Hash Object and all internal state of the message digest
								hashCopyImpl = hashImpl->CopyL();
								
								hashCopied = ETrue;
								
								INFO_PRINTF2(_L("*** HASH COPY - Bytes Read: %d ***"), readPosition);
								}
							else
								{
								//Update the message data within the Hash object with the new block
								if(hashCopied == EFalse)
									{
									hashImpl->Update(*sourceData);
									INFO_PRINTF2(_L("Hash Update - Bytes Read: %d"), readPosition);		
									}
								else
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:67,代码来源:hashincrementalhashwithcopystep.cpp


注:本文中的CHash::Final方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。