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


C++ Base64Encode函数代码示例

本文整理汇总了C++中Base64Encode函数的典型用法代码示例。如果您正苦于以下问题:C++ Base64Encode函数的具体用法?C++ Base64Encode怎么用?C++ Base64Encode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: decode_send

void decode_send(char serial_input[181]){
	char temp1[181] = {0};
        char sender[181] = {0};
        int rc = 0;
        printf("[DECODING: %s\n",serial_input);
        switch(serial_input[1])
        {
                case '3': //disable warning sercurity
			serial_input[1] = '2';
			sprintf(temp1, "005$%s$%s$%s", "rpi001", "ceslab", serial_input);
                        break;
		case '4': //get status autolight 1 2
			serial_input[1] = '3';
			sprintf(temp1, "005$%s$%s$%s", "rpi001", "ceslab", serial_input);
			break;
		case '6': //turn led 1 off
			serial_input[1] = '5';
			sprintf(temp1, "005$%s$%s$%s", "rpi001", "ceslab", serial_input);
			break;
		case '7': //turn led 2 on
			serial_input[1] = '6';
			sprintf(temp1, "005$%s$%s$%s", "rpi001", "ceslab", serial_input);
			break;
		case '8': //turn led 2 off
                        serial_input[1] = '6';
                        sprintf(temp1, "005$%s$%s$%s", "rpi001", "ceslab", serial_input);
                        break;
		case '9': //turn led 3 on
                        serial_input[1] = '7';
                        sprintf(temp1, "005$%s$%s$%s", "rpi001", "ceslab", serial_input);
                        break;
		case 'a': //turn led 3 off
                        serial_input[1] = '7';
                        sprintf(temp1, "005$%s$%s$%s", "rpi001", "ceslab", serial_input);
                        break;
		case 'b': //turn led 4 on
                        serial_input[1] = '8';
                        sprintf(temp1, "005$%s$%s$%s", "rpi001", "ceslab", serial_input);
                        break;
		case 'c': //turn led 4 off
                        serial_input[1] = '8';
                        sprintf(temp1, "005$%s$%s$%s", "rpi001", "ceslab", serial_input);
                        break;
		case 'e': //turn Autoled 1 off
                        serial_input[1] = 'd';
                        sprintf(temp1, "005$%s$%s$%s", "rpi001", "ceslab", serial_input);
                        break;
		case 'k': // detected opened door
			sprintf(temp1,"006$rpi001$ceslab$Door");
			break;
		default:
			sprintf(temp1, "005$%s$%s$%s", "rpi001", "ceslab", serial_input);
			break;
        }
        printf("[Detected] SEND data %s \n", temp1);
        rc = Base64Encode(temp1, sender, BUFFFERLEN);
        send(global_socket,sender,181,NULL);
}
开发者ID:ndksys01,项目名称:Firmware-Rpi-,代码行数:58,代码来源:servo.c

示例2: promise

already_AddRefed<Promise>
MediaKeySession::GenerateRequest(const nsAString& aInitDataType,
                                 const ArrayBufferViewOrArrayBuffer& aInitData,
                                 ErrorResult& aRv)
{
  nsRefPtr<DetailedPromise> promise(MakePromise(aRv));
  if (aRv.Failed()) {
    return nullptr;
  }

  if (!mUninitialized) {
    EME_LOG("MediaKeySession[%p,'%s'] GenerateRequest() failed, uninitialized",
            this, NS_ConvertUTF16toUTF8(mSessionId).get());
    promise->MaybeReject(NS_ERROR_DOM_INVALID_ACCESS_ERR,
                         NS_LITERAL_CSTRING("Session is already initialized in MediaKeySession.generateRequest()"));
    return promise.forget();
  }

  mUninitialized = false;

  nsTArray<uint8_t> data;
  if (aInitDataType.IsEmpty() ||
      !CopyArrayBufferViewOrArrayBufferData(aInitData, data)) {
    promise->MaybeReject(NS_ERROR_DOM_INVALID_ACCESS_ERR,
                         NS_LITERAL_CSTRING("Bad arguments to MediaKeySession.generateRequest()"));
    EME_LOG("MediaKeySession[%p,'%s'] GenerateRequest() failed, "
            "invalid initData or initDataType",
      this, NS_ConvertUTF16toUTF8(mSessionId).get());
    return promise.forget();
  }

  // Convert initData to base64 for easier logging.
  // Note: UpdateSession() Move()s the data out of the array, so we have
  // to copy it here.
  nsAutoCString base64InitData;
  if (EME_LOG_ENABLED()) {
    nsDependentCSubstring rawInitData(reinterpret_cast<const char*>(data.Elements()),
      data.Length());
    if (NS_FAILED(Base64Encode(rawInitData, base64InitData))) {
      NS_WARNING("Failed to base64 encode initData for logging");
    }
  }

  PromiseId pid = mKeys->StorePromise(promise);
  mKeys->GetCDMProxy()->CreateSession(Token(),
                                      mSessionType,
                                      pid,
                                      aInitDataType, data);

  EME_LOG("MediaKeySession[%p,'%s'] GenerateRequest() sent, "
          "promiseId=%d initData(base64)='%s'",
          this,
          NS_ConvertUTF16toUTF8(mSessionId).get(),
          pid,
          base64InitData.get());

  return promise.forget();
}
开发者ID:hobinjk,项目名称:gecko-dev,代码行数:58,代码来源:MediaKeySession.cpp

示例3: TPMinitialProvisioning

int TPMinitialProvisioning(void)
{
    if (EKserverAddr == NULL)
    {
        printf("TPM Manufacturer Endorsement Credential Server Address cannot be NULL\n");
        return -99;
    }
    RetrieveEndorsementCredentials(Base64Encode(HashEKPublicKey()));
    return 0;
}
开发者ID:AdditionalPylons,项目名称:tpm2.0-tools,代码行数:10,代码来源:tpm2_getmanufec.cpp

示例4: NS_ENSURE_ARG_POINTER

nsresult
SRICheckDataVerifier::VerifyHash(const SRIMetadata& aMetadata,
                                 uint32_t aHashIndex,
                                 const nsACString& aSourceFileURI,
                                 nsIConsoleReportCollector* aReporter)
{
  NS_ENSURE_ARG_POINTER(aReporter);

  nsAutoCString base64Hash;
  aMetadata.GetHash(aHashIndex, &base64Hash);
  SRILOG(("SRICheckDataVerifier::VerifyHash, hash[%u]=%s", aHashIndex, base64Hash.get()));

  nsAutoCString binaryHash;
  if (NS_WARN_IF(NS_FAILED(Base64Decode(base64Hash, binaryHash)))) {
    nsTArray<nsString> params;
    aReporter->AddConsoleReport(nsIScriptError::errorFlag,
                                NS_LITERAL_CSTRING("Sub-resource Integrity"),
                                nsContentUtils::eSECURITY_PROPERTIES,
                                aSourceFileURI, 0, 0,
                                NS_LITERAL_CSTRING("InvalidIntegrityBase64"),
                                const_cast<const nsTArray<nsString>&>(params));
    return NS_ERROR_SRI_CORRUPT;
  }

  uint32_t hashLength;
  int8_t hashType;
  aMetadata.GetHashType(&hashType, &hashLength);
  if (binaryHash.Length() != hashLength) {
    nsTArray<nsString> params;
    aReporter->AddConsoleReport(nsIScriptError::errorFlag,
                                NS_LITERAL_CSTRING("Sub-resource Integrity"),
                                nsContentUtils::eSECURITY_PROPERTIES,
                                aSourceFileURI, 0, 0,
                                NS_LITERAL_CSTRING("InvalidIntegrityLength"),
                                const_cast<const nsTArray<nsString>&>(params));
    return NS_ERROR_SRI_CORRUPT;
  }

  if (MOZ_LOG_TEST(SRILogHelper::GetSriLog(), mozilla::LogLevel::Debug)) {
    nsAutoCString encodedHash;
    nsresult rv = Base64Encode(mComputedHash, encodedHash);
    if (NS_SUCCEEDED(rv)) {
      SRILOG(("SRICheckDataVerifier::VerifyHash, mComputedHash=%s",
              encodedHash.get()));
    }
  }

  if (!binaryHash.Equals(mComputedHash)) {
    SRILOG(("SRICheckDataVerifier::VerifyHash, hash[%u] did not match", aHashIndex));
    return NS_ERROR_SRI_CORRUPT;
  }

  SRILOG(("SRICheckDataVerifier::VerifyHash, hash[%u] verified successfully", aHashIndex));
  return NS_OK;
}
开发者ID:marcoscaceres,项目名称:gecko-dev,代码行数:55,代码来源:SRICheck.cpp

示例5: Escape

// https://developer.twitter.com
// /en/docs/basics/authentication/guides/creating-a-signature.html
std::string Network::CalcSignature(
	const std::string &http_method, const std::string &base_url,
	const KeyValue &oauth_param, const KeyValue &query_param,
	const std::string &consumer_secret, const std::string &token_secret)
{
	// "Collecting parameters"
	// percent encode しつつ合成してキーでソートする
	KeyValue param;
	auto encode_insert = [this, &param](const KeyValue &map) {
		for (const auto &entry : map) {
			param.emplace(Escape(entry.first), Escape(entry.second));
		}
	};
	encode_insert(oauth_param);
	encode_insert(query_param);
	// 文字列にする
	// key1=value1&key2=value2&...
	std::string param_str;
	bool is_first = true;
	for (const auto &entry : param) {
		if (is_first) {
			is_first = false;
		}
		else {
			param_str += '&';
		}
		param_str += entry.first;
		param_str += '=';
		param_str += entry.second;
	}

	// "Creating the signature base string"
	// 署名対象
	std::string base = http_method;
	base += '&';
	base += Escape(base_url);
	base += '&';
	base += Escape(param_str);

	// "Getting a signing key"
	// 署名鍵は consumer_secret と token_secret をエスケープして & でつなぐだけ
	std::string key = Escape(consumer_secret);
	key += '&';
	key += Escape(token_secret);

	// "Calculating the signature"
	ShaDigest signature;
	HmacSha1(
		key.data(), key.size(),
		reinterpret_cast<const unsigned char *>(base.data()), base.size(),
		signature);

	return Base64Encode(signature, sizeof(signature));
}
开发者ID:yappy,项目名称:DollsKit,代码行数:56,代码来源:net.cpp

示例6: ToBase64

nsCString
ToBase64(const nsTArray<uint8_t>& aBytes)
{
  nsAutoCString base64;
  nsDependentCSubstring raw(reinterpret_cast<const char*>(aBytes.Elements()),
                            aBytes.Length());
  nsresult rv = Base64Encode(raw, base64);
  if (NS_WARN_IF(NS_FAILED(rv))) {
    return NS_LITERAL_CSTRING("[Base64EncodeFailed]");
  }
  return base64;
}
开发者ID:Danielzac,项目名称:gecko-dev,代码行数:12,代码来源:GMPUtils.cpp

示例7: trim_right

BOOL CSoftInfoQueryTask::CombineBodyContent(const SoftQueryInfoList &queryInfoList, string &bodyContent)
{
	try
	{
		// SID
		string sids;
		{
			ostringstream os;
			os.imbue(locale::classic());

			SoftQueryInfoCIter end = queryInfoList.end();
			for(SoftQueryInfoCIter it = queryInfoList.begin(); it != end; ++it)
			{
				os<<it->_id<<',';
			}

			sids = os.str();
			trim_right(sids, ",");
		}

		// 验证码
		string code = "&c=";
		{
			unsigned int crc32 = ::CRC32(0, sids.c_str(), static_cast<unsigned int>(sids.length()));

			static const char KEY[] = "kingsoftgrade2_%^}[793dkle";
			crc32 = ::CRC32(crc32, KEY, static_cast<unsigned int>(sizeof(KEY) - 1));

			ostringstream os;
			os.imbue(locale::classic());

			os<<hex<<crc32;
			code += os.str();
		}

		// 版本 & SID & 验证码
		string plainText = string("v=1_0&sid=") + sids + code;

		// base64
		DWORD sizeBase64 = Base64EncodeGetLength(static_cast<DWORD>(plainText.length()));

		auto_buffer<char> buffer(sizeBase64 + 1);
		if(buffer.empty()) return FALSE;

		sizeBase64 = Base64Encode(&buffer[0], plainText.c_str(), static_cast<DWORD>(plainText.length()));
		buffer[sizeBase64] = '\0';

		bodyContent = string("c=") + &buffer[0] + "\r\n";
		return TRUE;
	}
	catch(...) {}
	return FALSE;
}
开发者ID:6520874,项目名称:pcmanager,代码行数:53,代码来源:SoftInfoQuery.cpp

示例8: _video_send_ClientThread

static int _video_send_ClientThread()
{
	char *header, *init , *dest, *data;
	char buffer[181] = {0};
	char temp[181]={0};
	char temp1[181]={0};
	char combine[181]={0};

	char receiver[181] = {0};
	char sender[181] = {0};
	int rc = 0;

	// Send ice ifo to android
	memcpy(temp,mInfo_SendVideo,sizeof(temp));
	sprintf(combine,"002$%s$%s$%s",destBuf,originBuf,temp);
	rc = Base64Encode(combine, sender, BUFFFERLEN);
	send(global_socket,sender,181,NULL);

	printf ("=============== Send Video ===============\n");
	printf("[send video] send = %s\n", combine);
	printf("[send video] send[Encode] = %s\n", sender);

	//Receive ice info from android
	if(recv(global_socket, buffer, 181, NULL))
	{
		rc = Base64Decode(buffer, receiver, BUFFFERLEN);

		printf("[send video] receive = %s\n", buffer);
		printf("[send video] receive[Decode] = %s\n", receiver);

		header = strtok (receiver,"$");
		init = strtok (NULL,"$");
		dest = strtok (NULL,"$");
		data = strtok (NULL,"$");
		//printf("%s - %s\n",header ,data);

		int j=0;
		if (data!=NULL)
			while(j<strlen(data))
			{
				temp1[j] = *(data+j);
				j++;
			}

		if(!strcmp(header,"002"))
		{
			AndroidInfo_SendVideo = (gchar*)malloc(sizeof(gchar)*181);
			memcpy(AndroidInfo_SendVideo, temp1, sizeof(temp1));
			flag_trans = 1;
			return 0;
		}
	}
}
开发者ID:cxp1991,项目名称:WORKING,代码行数:53,代码来源:send_video.c

示例9: copyKeys

static void copyKeys(QSettings &old, SettingsObject *object)
{
    foreach (const QString &key, old.childKeys()) {
        QVariant value = old.value(key);
        if ((QMetaType::Type)value.type() == QMetaType::QDateTime)
            object->write(key, value.toDateTime());
        else if ((QMetaType::Type)value.type() == QMetaType::QByteArray)
            object->write(key, Base64Encode(value.toByteArray()));
        else
            object->write(key, value.toString());
    }
}
开发者ID:bookie988,项目名称:ricochet,代码行数:12,代码来源:main.cpp

示例10: auth

void
HTTPRequestHeader::SetAuthentication(int type, std::string userName, std::string password)
{
	if (type != HTTP_AUTH_TYPE_BASIC)
		return;

	std::string auth("Basic ");
	std::string authString;
	authString.append(userName).append(":").append(password);
	authString = Base64Encode(authString);
	auth.append(authString);
	SetValue("Authorization", auth);
}
开发者ID:jackburton79,项目名称:agent,代码行数:13,代码来源:HTTPRequestHeader.cpp

示例11: desencode

static void desencode(char *content, char *content_in)
{
	char de_content[1024] = {0};
	DES_cblock key_cblock;
	DES_string_to_key(key, &key_cblock);
	DES_key_schedule schedule;
	DES_set_key_checked(&key_cblock, &schedule);
	DES_ncbc_encrypt(content, de_content, strlen(content), &schedule, &key_cblock, DES_ENCRYPT  );
	DES_string_to_key(key, &key_cblock);
	DES_set_key_checked(&key_cblock, &schedule);
	printf("key_cblock= %s\n", key_cblock);
	Base64Encode(de_content, strlen(de_content), content_in, sizeof(content_in));
}
开发者ID:helight,项目名称:helight_code,代码行数:13,代码来源:tt.c

示例12: promise

already_AddRefed<Promise>
MediaKeySession::Update(const ArrayBufferViewOrArrayBuffer& aResponse, ErrorResult& aRv)
{
  nsRefPtr<DetailedPromise> promise(MakePromise(aRv,
    NS_LITERAL_CSTRING("MediaKeySession.update")));
  if (aRv.Failed()) {
    return nullptr;
  }
  nsTArray<uint8_t> data;
  if (IsClosed() || !mKeys->GetCDMProxy()) {
    promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR,
                         NS_LITERAL_CSTRING("Session is closed or was not properly initialized"));
    EME_LOG("MediaKeySession[%p,'%s'] Update() failed, session is closed or was not properly initialised.",
            this, NS_ConvertUTF16toUTF8(mSessionId).get());
    return promise.forget();
  }
  if (!CopyArrayBufferViewOrArrayBufferData(aResponse, data)) {
    promise->MaybeReject(NS_ERROR_DOM_INVALID_ACCESS_ERR,
                         NS_LITERAL_CSTRING("Invalid response buffer"));
    EME_LOG("MediaKeySession[%p,'%s'] Update() failed, invalid response buffer",
            this, NS_ConvertUTF16toUTF8(mSessionId).get());
    return promise.forget();
  }


  // Convert response to base64 for easier logging.
  // Note: UpdateSession() Move()s the data out of the array, so we have
  // to copy it here.
  nsAutoCString base64Response;
  if (EME_LOG_ENABLED()) {
    nsDependentCSubstring rawResponse(reinterpret_cast<const char*>(data.Elements()),
      data.Length());
    if (NS_FAILED(Base64Encode(rawResponse, base64Response))) {
      NS_WARNING("Failed to base64 encode response for logging");
    }
  }

  PromiseId pid = mKeys->StorePromise(promise);
  mKeys->GetCDMProxy()->UpdateSession(mSessionId,
                                      pid,
                                      data);

  EME_LOG("MediaKeySession[%p,'%s'] Update() sent to CDM, "
          "promiseId=%d Response(base64)='%s'",
           this,
           NS_ConvertUTF16toUTF8(mSessionId).get(),
           pid,
           base64Response.get());

  return promise.forget();
}
开发者ID:rhelmer,项目名称:gecko-dev,代码行数:51,代码来源:MediaKeySession.cpp

示例13: ShowErroTips

UINT DlgModPass::ModPwdThread(LPVOID pParam)
{
	DlgModPass* pDlg = static_cast<DlgModPass*>(pParam);
	CXTraderApp* pApp = g_App;
	CAppCfgs& s = g_App->m_cfg;

	char szOriPass[MAX_PATH],szNewPass[MAX_PATH];
	
	if (pDlg->m_szNewPass.IsEmpty()||pDlg->m_szOldPass.IsEmpty()||pDlg->m_szNewCfm.IsEmpty())
	{
		ShowErroTips(IDS_STREMPTY,IDS_STRTIPS);
		return 0;
	}
	
	if (pDlg->m_szNewPass.Compare(pDlg->m_szNewCfm)!=0)
	{
		ShowErroTips(IDS_CFMPASSERR,IDS_STRTIPS);
		return 0;
	}
	
	uni2ansi(CP_ACP,(LPTSTR)(LPCTSTR)pDlg->m_szOldPass,szOriPass);
	uni2ansi(CP_ACP,(LPTSTR)(LPCTSTR)pDlg->m_szNewPass,szNewPass);
	if (pDlg->m_itype==0)
	{	
		pApp->m_cT->ReqUserPwdUpdate(szNewPass,szOriPass);
		
		DWORD dwRet = WaitForSingleObject(g_hEvent,WAIT_MS);
		if (dwRet==WAIT_OBJECT_0)
		{
			strcpy(s.m_sPwd,szNewPass);
			ResetEvent(g_hEvent);
			///////±£´æÐ޸ĵÄÃÜÂë////////
            size_t iSize = s.m_pInfVec.size();
				
			TThostFtdcEncPasswordType szEncPass;
			Base64Encode(szEncPass, s.m_sPwd, 0);
			if (iSize>0){ strcpy(s.m_pInfVec[iSize-1].szPass,szEncPass); }
		}	
	}
	if (pDlg->m_itype==1)
	{
		pApp->m_cT->ReqTdAccPwdUpdate(szNewPass,szOriPass);
		
		DWORD dwRet = WaitForSingleObject(g_hEvent,WAIT_MS);
		if (dwRet==WAIT_OBJECT_0)
		{ ResetEvent(g_hEvent); }
	}

	pDlg->m_pModPass = NULL;
	return 0;
}
开发者ID:AutoCoder,项目名称:xtrader_lite,代码行数:51,代码来源:DlgModPass.cpp

示例14: Value

const char *MSNObject::Base64Encoded(void) {
	if (fBase64.Length() == 0) {
		BString temp = Value();
		temp << '\0';
	
		char *b64 = Base64Encode(temp.String(), temp.Length());
		fBase64 = b64;
		
		free(b64);
		
	};
	
	return fBase64.String();
};
开发者ID:louisdem,项目名称:IMKit,代码行数:14,代码来源:MSNObject.cpp

示例15: GetEncodedVersion

static int GetEncodedVersion(char *buf)
{
	char version[20] = {0};
	char tmp[9] = {0};
	
	sprintf(tmp, "%02x%02x%02x%02x", magic[0], magic[1], magic[2], magic[3]);
	
	memcpy(version, ClientVersion, strlen(ClientVersion));
	memcpy(version+16, magic, 4);
	
	EORMix(version, tmp, 16);
	EORMix(version, H3CKey, 20);
	
	return Base64Encode(version, buf, 20);
}
开发者ID:brucexin,项目名称:xclient,代码行数:15,代码来源:eap.c


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