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


C++ Name::getCompFromBackAsString方法代码示例

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


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

示例1: runDataCallback

void remote::runDataCallback(Name name, Ccnx::PcoPtr pco)
{
    std::clog<<"data callback name:  "<<name<<std::endl;
    Ccnx::BytesPtr content = pco->contentPtr ();
    std::clog<<"data callback content:  "<<content<<std::endl;
    std::string action = name.getCompAsString(4); //action
    std::string consumer = name.getCompAsString(2); //consumer
    std::string producer = name.getCompAsString(1); //producer
    std::string endPoint = name.getCompAsString(3); //endpoint
    std::string prefix = name.getCompAsString(0);
    std::string app;
    std::string session;
    vector <string> app_session;
    split(prefix, app_session, "_");        	
    app = app_session[0];
    session = app_session[1];
    
    int size = name.size();    
    std::string lastComponent =name.getCompAsString(size-1);
    vector <string> splitPara;
    split(lastComponent, splitPara, ",");
    if (splitPara.size() == 1 && splitPara[0].compare("code=0") == 0)
        return;
    
    int code;
    int version =0;
   	int flag; //1: first packet 0:later packets
    int seqnum = 0;
    int chunkSize = 0;
    if (splitPara.size() == 3){
        flag = 1;
        vector <string> tmp1,tmp2,tmp3;
        split(splitPara[0], tmp1, "=");
        code = atoi(tmp1[1].c_str());
        split(splitPara[1], tmp2, "=");
        version = atoi(tmp2[1].c_str());
        split(splitPara[2], tmp3, "=");
        chunkSize = atoi(tmp3[1].c_str());
        seqnum = 1;
    }
    else{
        flag = 0;
        std::string tmp = name.getCompFromBackAsString(1);
        vector <string> chunkTmp;
        split(tmp, chunkTmp, "=");
        seqnum = atoi(chunkTmp[1].c_str());
//        cout<<"seqnum chunk"<<seqnum<<"  "<<chunk<<endl;
    }

    OrganizerSession *oSession;
    ParticipantSession *pSession;
    Context::instance()->retrieveSession(app, session, &oSession, &pSession);

    if (action.compare("fetch") == 0)
    {
    	if (endPoint.compare("public-key") == 0)
    	{
            if (pSession)
            {
    			pSession->recvPublicKeyRemote(producer, version, seqnum, chunkSize,
        	string ((char*)Ccnx::head (*content), content->size ()));    			
            }
            if (oSession)
            {
    			oSession->recvPublicKeyRemote(producer, version, seqnum, chunkSize,
        	string ((char*)Ccnx::head (*content), content->size ()));    			
            }		  		
    	}
    	 
      if (endPoint.compare("shared-key") == 0)
      {
          //decrypt
          std::string privateKey;
          privateKey = KeyDB::instance().getPriKey();
          EVP_PKEY *pri_key = KeyDB::instance().str2priKey(privateKey);
          RSA *decrypt_key;
          /*for test*/
          FILE *rsa_pkey_file;
          rsa_pkey_file = fopen("../db/pri1.pem", "r");
          
          if (!PEM_read_RSAPrivateKey(rsa_pkey_file, &decrypt_key, NULL, NULL))
          {
              fprintf(stderr, "Error loading RSA Private Key File.\n");
              ERR_print_errors_fp(stderr);
          }
          /*test end*/
          
          std::string encrypt_string = string ((char*)Ccnx::head (*content), content->size ());
          cout<<encrypt_string<<endl;
          char *encrypt = (char *)(encrypt_string.c_str());
          char *decrypt = NULL;
          int encrypt_len  = content->size();
          cout<<"encrypt_len"<<encrypt_len<<endl;
//          decrypt_key = EVP_PKEY_get1_RSA(pri_key);  //important line
          decrypt = (char *)malloc(encrypt_len);
          memset(decrypt,0,(encrypt_len));
          char *err = (char *)malloc(130);
          if(RSA_private_decrypt(encrypt_len, (unsigned char*)encrypt, (unsigned char*)decrypt, decrypt_key, RSA_PKCS1_OAEP_PADDING) == -1)
          {
              ERR_load_crypto_strings();
//.........这里部分代码省略.........
开发者ID:whynpc,项目名称:NdnKeyManagementTool,代码行数:101,代码来源:remote.cpp


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