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


C++ TDes8::Format方法代码示例

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


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

示例1: InterfaceToBearer

/**
Convert data from the API's form (as we're given it by RemCon) the
bearer-specific form.
*/
TInt CCoreSerialConverter::InterfaceToBearer(TUid aInterfaceUid,
		TUint aOperationId,
		const TDesC8& aData,
		TRemConMessageType aMsgType,
		TDes8& aBearerData) const
	{
	TInt ret = KErrCorrupt;

	if ( aData.Length() <= 10 )
		{
		if ( aMsgType == ERemConCommand )
			{
			aBearerData.Format(_L8("0x%08x 0x%02x %S %S"), aInterfaceUid, aOperationId, &KCmdText(), &aData);
			// Pad it up in case aData was less than 4 characters.
			while ( aBearerData.Length() < KRemConSerialBearerMessageLength )
				{
				aBearerData.Append(_L8(" "));
				}
			ret = KErrNone;
			}
		else if ( aMsgType == ERemConResponse )
			{
			aBearerData.Format(_L8("0x%08x 0x%02x %S %S"), aInterfaceUid, aOperationId, &KRspText(), &aData);
			// Pad it up in case aData was less than 4 characters.
			while ( aBearerData.Length() < KRemConSerialBearerMessageLength )
				{
				aBearerData.Append(_L8(" "));
				}
			ret = KErrNone;
			}
		}

	return ret;
	}
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:38,代码来源:coreserialconverter.cpp

示例2: ParseUUID

static void ParseUUID(TDes8& aBuf, TUUID aUuid) {
	TPtrC8 uuid(aUuid.ShortestForm());
	const TUint8* ptr = uuid.Ptr();

	switch(uuid.Length()) {
	case 2:
		aBuf.Format(_L8("0x%04X"), BigEndian::Get16(ptr));
		break;
	case 4:
		aBuf.Format(_L8("0x%08X"), BigEndian::Get32(ptr));
		break;
	case 16:
		aBuf.Format(_L8("%08X-%08X-%08X-%08X"), BigEndian::Get32(ptr),
			BigEndian::Get32(ptr + 4), BigEndian::Get32(ptr + 8),
			BigEndian::Get32(ptr + 12));
		break;
	default:
		DEBIG_PHAT_ERROR;
	}
}
开发者ID:Felard,项目名称:MoSync,代码行数:20,代码来源:bluetooth.cpp

示例3: passwordHash

inline void CPppMsChap2::GenerateAuthenticatorResponseL(
    const TDesC16& aPassword,
    const TDesC8& aNTResponse,
    const TDesC8& aPeerChallenge,
    const TDesC8& aAuthenticatorChallenge,
    const TDesC8& aUserName,
    TDes8& aAuthenticatorResponse)
/**
   Generates the expected MS-CHAP-V2 Authenticator Response Value.
   @param aPassword [in] The Microsoft Windows NT password (0 to 256
   Unicode char).
   @param aNTResponse [in] The MS-CHAP-V2 NT-Response (24 octets).
   @param aPeerChallenge [in] The Peer Challenge (16 octets).
   @param aAuthenticatorChallenge [in] The Authenticator Challenge (16
   octets).
   @param aUserName [in] The Microsoft Windows NT username (0 to 256
   char).
   @param aAuthenticatorResponse [out] The expected MS-CHAP-V2
   Authenticator Response Value encoded in the format
   "S=<auth_string>" as specified in RFC 2759 (42 octets).
   @note This function implements the GenerateAuthenticatorResponse
   routine specified in RFC 2759.
   @internalComponent
*/
{
    ASSERT(aPassword.Length()<=KPppMsChapMaxNTPasswordLength);
    ASSERT(aNTResponse.Length() == KPppMsChap2NTResponseSize);
    ASSERT(aPeerChallenge.Length() ==
           KPppMsChap2PeerChallengeSize);
    ASSERT(aAuthenticatorChallenge.Length() ==
           KPppMsChap2AuthenticatorChallengeSize);
    ASSERT(aUserName.Length()<=KPppMsChapMaxNTUserNameLength);
    ASSERT(aAuthenticatorResponse.Length() ==
           KPppMsChap2AuthenticatorResponseSize);

    HBufC8* passwordHashBuf=HBufC8::NewMaxLC(KPppMsChap2HashSize);
    TPtr8 passwordHash(passwordHashBuf->Des());

    NtPasswordHashL(aPassword, passwordHash);

    HashNtPasswordHashL(passwordHash, passwordHash);

    CSHA1* sha1 = CSHA1::NewL();
    CleanupStack::PushL(sha1);

// A magic string literal specified in RFC 2759 used in reponse
// generation by the GenerateAuthenticatorResponse routine for SHA-1
// encryption.
    _LIT8(KMagic1, "Magic server to client signing constant");


    sha1->Update(passwordHash);
    sha1->Update(aNTResponse);
    TPtrC8 hash(sha1->Final(KMagic1));


    HBufC8* challengeHashBuf =
        HBufC8::NewMaxLC(KPppMsChap2ChallengeHashSize);
    TPtr8 challengeHash(challengeHashBuf->Des());
    ChallengeHashL(aPeerChallenge,
                   aAuthenticatorChallenge,
                   aUserName,
                   challengeHash);

// Another magic string literal specified in RFC 2759 used in reponse
// generation by the GenerateAuthenticatorResponse routine for SHA-1
// encryption.
    _LIT8(KMagic2, "Pad to make it do more than one iteration");


    sha1->Update(hash);
    sha1->Update(challengeHash);
    const TUint8* pHash = sha1->Final(KMagic2).Ptr();


    _LIT8(KFormat,
          "S=%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X"
          "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X");
    aAuthenticatorResponse.Format(KFormat,
                                  *pHash,
                                  *(pHash + 1),
                                  *(pHash + 2),
                                  *(pHash + 3),
                                  *(pHash + 4),
                                  *(pHash + 5),
                                  *(pHash + 6),
                                  *(pHash + 7),
                                  *(pHash + 8),
                                  *(pHash + 9),
                                  *(pHash + 10),
                                  *(pHash + 11),
                                  *(pHash + 12),
                                  *(pHash + 13),
                                  *(pHash + 14),
                                  *(pHash + 15),
                                  *(pHash + 16),
                                  *(pHash + 17),
                                  *(pHash + 18),
                                  *(pHash + 19));

//.........这里部分代码省略.........
开发者ID:kuailexs,项目名称:symbiandump-os2,代码行数:101,代码来源:mschap2.cpp


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