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


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

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


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

示例1: doTestStepL


//.........这里部分代码省略.........
							//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
									{
									hashCopyImpl->Update(*sourceData);
									INFO_PRINTF2(_L("Hash Update (Copy) - Bytes Read: %d"), readPosition);		
									}
								}
							
							CleanupStack::PopAndDestroy(sourceData);
							
								
							}while(hashComplete == EFalse);
						
						//Create a NULL TCharacteristics pointer
						const TCharacteristics* charsPtr(NULL);
						
						//Retrieve the characteristics for the hash implementation object
						TRAP_LOG(err, hashImpl->GetCharacteristicsL(charsPtr));
						
						//Static cast the characteristics to type THashCharacteristics
						const THashCharacteristics* hashCharsPtr = static_cast<const THashCharacteristics*>(charsPtr);
						
						//The hash output size is returned in Bits, divide by 8 to get the Byte size
						TInt hashSize = hashCharsPtr->iOutputSize/8;
						
						//Retrieve the final 8bit hash value and convert to 16bit												
						HBufC* hashData = HBufC::NewLC(hashSize);
						TPtr hashPtr = hashData->Des();
						
						//Copy the hashed content into the heap based descriptor
						hashPtr.Copy(hashStr);
						
					 	//Take the 16bit descriptor and convert the string to hexadecimal
						TVariantPtrC convertHash;
						convertHash.Set(hashPtr);
						HBufC* hashResult = convertHash.HexStringLC();
						
						INFO_PRINTF2(_L("*** Hashed Data: %S ***"),&*hashResult);
						INFO_PRINTF2(_L("*** Expected Hash: %S ***"),&expectedHash);
						
						//If the returned hash value matches the expected hash, Pass the test		
						if(*hashResult == expectedHash)
							{
							INFO_PRINTF1(_L("*** Hash - Incremental Hash with Copy : PASS ***"));
							SetTestStepResult(EPass);	
							}
						else
							{
							ERR_PRINTF2(_L("*** FAIL: Hashed and Expected Value Mismatch  ***"), err);
							SetTestStepResult(EFail);	
							}
								
						CleanupStack::PopAndDestroy(hashResult);
						CleanupStack::PopAndDestroy(hashData);						
						
						delete hashCopyImpl;
						}
					
					//Cleanup the Source RFile	
					CleanupStack::PopAndDestroy();	
					}

				fsSession.Close();	
				
				CleanupStack::PopAndDestroy(hashImpl);
				}
			else
				{
				ERR_PRINTF2(_L("*** FAIL: Failed to Create Hash Object - %d ***"), err);
				SetTestStepResult(EFail);	
				}
			}
			
		}
		
	INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
	return TestStepResult();
	}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:101,代码来源:hashincrementalhashwithcopystep.cpp

示例2: doTestStepL


//.........这里部分代码省略.........
				TPtr8 keyStrPtr = keyStr->Des();
				
				keyStrPtr.Copy(encryptKey);
				
				//Create an new CryptoParams object to encapsulate the invalid key type and key string
				CCryptoParams* keyParams = CCryptoParams::NewL();
				CleanupStack::PushL(keyParams);
				keyParams->AddL(*keyStr,keyType);
				
				//Create a valid CKey Object
				TKeyProperty keyProperty;
				CKey* key = CKey::NewL(keyProperty,*keyParams);
				CleanupStack::PushL(key);
				
				//Construct an initial hash object with NO key, Catching any possible Leaves			
				TRAPD(err,CHashFactory::CreateHashL(
									hashHmacImpl,
									algorithmUid,
									operationModeUid,
									NULL,
									NULL));
									
										
				if(hashHmacImpl && (err == KErrNone))
					{
					
					//Push the Implementation Object onto the Cleanup Stack
					CleanupStack::PushL(hashHmacImpl);
					
					//Create a NULL TCharacteristics pointer
					const TCharacteristics* charsPtrA(NULL);
					
					//Retrieve the characteristics for the hash implementation object
					TRAP_LOG(err, hashHmacImpl->GetCharacteristicsL(charsPtrA));
					
					//Static cast the characteristics to type THashCharacteristics
					const THashCharacteristics* hashCharsPtrA = static_cast<const THashCharacteristics*>(charsPtrA);
					
					//The hash output size is returned in Bits, divide by 8 to get the Byte size
					TInt hashSize = hashCharsPtrA->iOutputSize/8;
					
					//Retrieve the final 8bit hash value and convert to 16bit												
					HBufC* hashDataA = HBufC::NewLC(hashSize);
					TPtr hashPtrA = hashDataA->Des();
					
					hashPtrA.Copy(hashHmacImpl->Hash(*sourceData));
					
					//Take the 16bit descriptor and convert the string to hexadecimal
					TVariantPtrC convertHash;
					convertHash.Set(hashPtrA);
					
					HBufC* resultA = convertHash.HexStringLC();							
						
					INFO_PRINTF2(_L("*** Hashed Data: %S ***"),&*resultA);
					INFO_PRINTF2(_L("*** Expected Hash: %S ***"),&expectedHash);
					
					if(*resultA == expectedHash)
						{
						INFO_PRINTF1(_L("*** PRIMARY HASH VALID - STAGE 1 PASS ***"));
						
						//Set the valid key within the Hmac Implementation Object
						TRAP(err,hashHmacImpl->SetKeyL(*key));
						
						if(err!=KErrNone)
							{
							ERR_PRINTF2(_L("*** ERROR %d: Setting Key ***"),err);
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:67,代码来源:hmacsetoperationmodecheckingstep.cpp


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