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


C++ OTASCIIArmor类代码示例

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


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

示例1: locker

QString MTContactHandler::GetContactName(int nContactID)
{
    QMutexLocker locker(&m_Mutex);

    QString str_select = QString("SELECT `contact_display_name` FROM `contact` WHERE `contact_id`='%1' LIMIT 0,1").arg(nContactID);

    int nRows = DBHandler::getInstance()->querySize(str_select);

    for(int ii=0; ii < nRows; ii++)
    {
        //Extract data
        QString contact_name = DBHandler::getInstance()->queryString(str_select, 0, ii);

        if (!contact_name.isEmpty())
        {
//          qDebug() << QString("About to decode name: %1").arg(contact_name);

            //Decode base64.
            OTASCIIArmor ascName;
            ascName.Set(contact_name.toStdString().c_str());
            OTString strName(ascName);
            contact_name = QString(strName.Get());
        }
        //---------------------------------------------------
        return contact_name; // In practice there should only be one row.
    }

    return ""; // Didn't find anyone.
}
开发者ID:BugFreeSoftware,项目名称:Moneychanger,代码行数:29,代码来源:contacthandler.cpp

示例2:

// This version base64-DECODES the ascii-armored string passed in,
// and then sets the decoded plaintext string onto this object.
String::String(const OTASCIIArmor& strValue)
    : length_(0)
    , position_(0)
    , data_(nullptr)
{
    //    Initialize();

    if (strValue.Exists()) strValue.GetString(*this);
}
开发者ID:Kodachi75,项目名称:opentxs,代码行数:11,代码来源:String.cpp

示例3: OT_ASSERT

// static
bool OTKeyring::KWallet_RetrieveSecret(const OTString& strUser,
                                       OTPassword& thePassword,
                                       const std::string& str_display)
{
    OT_ASSERT(strUser.Exists());

    KWallet::Wallet* pWallet = OTKeyring::OpenKWallet();

    if (nullptr != pWallet) {
        const QString qstrKey(strUser.Get());
        QString qstrPwd;

        // Get the password
        //
        if (pWallet->readPassword(qstrKey, qstrPwd) == 0) {
            const std::string str_password =
                qstrPwd.toStdString(); // todo security: notice str_password
                                       // isn't zero'd here.

            OTString strData(str_password);
            OTASCIIArmor ascData;

            const bool bLoaded =
                strData.Exists() && ascData.LoadFromString(strData);
            strData.zeroMemory();

            if (!bLoaded)
                otErr << __FUNCTION__ << ": Failed trying to decode secret "
                                         "from KWallet contents.\n";
            else {
                OTData thePayload(ascData);
                ascData.zeroMemory();
                if (thePayload.IsEmpty())
                    otErr << __FUNCTION__ << ": Failed trying to decode secret "
                                             "OTData from OTASCIIArmor from "
                                             "KWallet contents.\n";
                else {
                    thePassword.setMemory(thePayload.GetPayloadPointer(),
                                          thePayload.GetSize());
                    thePayload.zeroMemory(); // for security.
                    return true;
                }
            }
        }
        else
            otErr << __FUNCITON__
                  << ": Failed trying to retrieve secret from KWallet.\n";
    }

    // Not an error: what if it just hasn't been set there yet?
    //
    otWarn << "OTKeyring::KWallet_RetrieveSecret: No secret found.\n";

    return false;
}
开发者ID:Kodachi75,项目名称:opentxs,代码行数:56,代码来源:OTKeyring.cpp

示例4: atol

int OTPurse::ProcessXMLNode(irr::io::IrrXMLReader*& xml)
{
    if (!strcmp("purse", xml->getNodeName()))
    {
        OTString strServerID, strUserID, strAssetID, strTotalValue;


        m_strVersion	= xml->getAttributeValue("version");
        strUserID		= xml->getAttributeValue("userID");
        strServerID		= xml->getAttributeValue("serverID");
        strAssetID		= xml->getAttributeValue("assetTypeID");
        strTotalValue	= xml->getAttributeValue("totalValue");

        m_AssetID.SetString(strAssetID);
        m_UserID.SetString(strUserID);
        m_ServerID.SetString(strServerID);

        m_lTotalValue = 0;

        if (strTotalValue.Exists() && (atol(strTotalValue.Get()) > 0))
            m_lTotalValue = atol(strTotalValue.Get());

        OTLog::vOutput(4, "Loaded purse...\n ServerID: %s\n UserID: %s\n Asset ID: %s\n----------\n", strServerID.Get(),
                       strUserID.Get(), strAssetID.Get());

        return 1;
    }

    else if (!strcmp("token", xml->getNodeName()))
    {
        OTASCIIArmor * pArmor = new OTASCIIArmor;

        OT_ASSERT(NULL != pArmor);

        if (!LoadEncodedTextField(xml, *pArmor) || !pArmor->Exists())
        {
            OTLog::Error("Error in OTPurse::ProcessXMLNode: token field without value.\n");

            delete pArmor;
            pArmor = NULL;

            return (-1); // error condition
        }
        else
        {
            m_dequeTokens.push_front(pArmor);
        }

        return 1;
    }

    return 0;
}
开发者ID:piotreksz,项目名称:Open-Transactions,代码行数:53,代码来源:OTPurse.cpp

示例5: tag

void OTSubkey::UpdateContents()
{
    m_xmlUnsigned.Release();

    Tag tag("keyCredential");

    // a hash of the nymIDSource
    tag.add_attribute("nymID", GetNymID().Get());
    // Hash of the master credential that signed this subcredential.
    tag.add_attribute("masterID", GetMasterCredID().Get());

    if (GetNymIDSource().Exists()) {
        OTASCIIArmor ascSource;
        // A nym should always verify through its own
        // source. (Whatever that may be.)
        ascSource.SetString(GetNymIDSource());
        tag.add_tag("nymIDSource", ascSource.Get());
    }
    // MASTER-SIGNED INFO
    if (OTSubcredential::credMasterSigned == m_StoreAs ||
        OTSubcredential::credPrivateInfo == m_StoreAs) {
        UpdatePublicContentsToTag(tag);
    }
    // PUBLIC INFO (signed by subkey, contains master signed info.)
    if (OTSubcredential::credPublicInfo == m_StoreAs ||
        OTSubcredential::credPrivateInfo == m_StoreAs) {
        // GetMasterSigned() returns the contract
        // containing the master-signed contents
        // from the above block.
        OTASCIIArmor ascMasterSigned(GetMasterSigned());

        // Contains all the public info, signed by the master key.
        // Packaged up here inside a final, subkey-signed credential.
        tag.add_tag("masterSigned", ascMasterSigned.Get());
    }
    // PRIVATE INFO
    //
    // If we're saving the private credential info...
    if (OTSubcredential::credPrivateInfo == m_StoreAs) {
        UpdatePublicCredentialToTag(tag);
        UpdatePrivateContentsToTag(tag);
    }

    // <=== SET IT BACK TO DEFAULT BEHAVIOR. Any other state
    // processes ONCE, and then goes back to this again.
    m_StoreAs = OTSubcredential::credPrivateInfo;

    std::string str_result;
    tag.output(str_result);

    m_xmlUnsigned.Concatenate("%s", str_result.c_str());
}
开发者ID:yamamushi,项目名称:opentxs,代码行数:52,代码来源:OTSubkey.cpp

示例6: strLedgerAcctID

// SignContract will call this function at the right time.
void OTLedger::UpdateContents() // Before transmission or serialization, this is where the ledger saves its contents 
{
	// Notice I use the PURPORTED Account ID and Server ID to create the output. That's because
	// I don't want to inadvertantly substitute the real ID for a bad one and then sign it.
	// So if there's a bad one in there when I read it, THAT's the one that I write as well!
	OTString strType, strLedgerAcctID(GetPurportedAccountID()), strLedgerAcctServerID(GetPurportedServerID()),
		strUserID(GetUserID());
	
	switch (m_Type) {
		case OTLedger::message:
			strType.Set("message");
			break;
		case OTLedger::inbox:
			strType.Set("inbox");
			break;
		case OTLedger::outbox:
			strType.Set("outbox");
			break;
		default:
			strType.Set("error-unknown");
			break;
	}
	
	// I release this because I'm about to repopulate it.
	m_xmlUnsigned.Release();
	
	//	m_xmlUnsigned.Concatenate("<?xml version=\"%s\"?>\n\n", "1.0");		
	
	m_xmlUnsigned.Concatenate("<accountLedger version=\"%s\"\n type=\"%s\"\n accountID=\"%s\"\n userID=\"%s\"\n"
							  "serverID=\"%s\" >\n\n", m_strVersion.Get(), strType.Get(), 
							  strLedgerAcctID.Get(), strUserID.Get(), strLedgerAcctServerID.Get());		
	
	// loop through the transactions and print them out here.
	OTTransaction * pTransaction = NULL;
	
	for (mapOfTransactions::iterator ii = m_mapTransactions.begin(); 
		 ii != m_mapTransactions.end(); ++ii)
	{
		if ((pTransaction = (*ii).second)) // if pointer not null
		{
			OTString strTransaction;
			pTransaction->SaveContract(strTransaction);
			
			OTASCIIArmor ascTransaction;
			ascTransaction.SetString(strTransaction, true); // linebreaks = true
			
			m_xmlUnsigned.Concatenate("<transaction>\n%s</transaction>\n\n", ascTransaction.Get());
		}
	}
	
	m_xmlUnsigned.Concatenate("</accountLedger>\n");				
}
开发者ID:rhan3488,项目名称:Open-Transactions,代码行数:53,代码来源:OTLedger.cpp

示例7: ascMasterSigned

void OTSubkey::UpdateContents()
{
	m_xmlUnsigned.Release();
    
	m_xmlUnsigned.Concatenate("<keyCredential nymID=\"%s\"\n" // a hash of the nymIDSource
							  " masterCredentialID=\"%s\" >\n\n", // Hash of the master credential that signed this subcredential.
							  this->GetNymID().Get(), this->GetMasterCredID().Get());
    
    if (this->GetNymIDSource().Exists())
    {
        OTASCIIArmor ascSource;
        ascSource.SetString(this->GetNymIDSource()); // A nym should always verify through its own source. (Whatever that may be.)
        m_xmlUnsigned.Concatenate("<nymIDSource>\n%s</nymIDSource>\n\n", ascSource.Get());
    }
    // --------------------------------------------
    // MASTER-SIGNED INFO
    //
    if ((OTSubcredential::credMasterSigned == m_StoreAs) || // MASTER-SIGNED INFO
        (OTSubcredential::credPrivateInfo  == m_StoreAs))
    {
        // --------------------------------------------
        this->UpdateMasterPublicToString(m_xmlUnsigned);
        // --------------------------------------------
        this->UpdatePublicContentsToString(m_xmlUnsigned);
    }
    // --------------------------------------------
    // PUBLIC INFO
    //
    if ((OTSubcredential::credPublicInfo  == m_StoreAs)  || // PUBLIC INFO (signed by subkey, contains master signed info.)
        (OTSubcredential::credPrivateInfo == m_StoreAs))
    {
        OTASCIIArmor ascMasterSigned(this->GetMasterSigned()); // GetMasterSigned() returns the contract containing the master-signed contents from the above block.
        m_xmlUnsigned.Concatenate("<masterSigned>\n%s</masterSigned>\n\n", // Contains all the public info, signed by the master key.
                                  ascMasterSigned.Get());                  // Packaged up here inside a final, subkey-signed credential.
    }
	// -------------------------------------------------
    // PRIVATE INFO
    //
    // If we're saving the private credential info...
    // 
    if (OTSubcredential::credPrivateInfo == m_StoreAs)  // PRIVATE INFO
    {
        this->UpdatePublicCredentialToString(m_xmlUnsigned);
        // -------------------------------------
        this->UpdatePrivateContentsToString(m_xmlUnsigned);
    }
	// -------------------------------------------------	
	m_xmlUnsigned.Concatenate("</keyCredential>\n");
    // --------------------------------------------
    m_StoreAs = OTSubcredential::credPrivateInfo;  // <=== SET IT BACK TO DEFAULT BEHAVIOR. Any other state processes ONCE, and then goes back to this again.
}
开发者ID:BwRy,项目名称:Open-Transactions,代码行数:51,代码来源:OTSubkey.cpp

示例8: Serialize

void OTClause::Serialize(Tag& parent) const
{
    OTASCIIArmor ascCode;

    if (m_strCode.GetLength() > 2)
        ascCode.SetString(m_strCode);
    else
        otErr << "Empty script code in OTClause::Serialize()\n";

    TagPtr pTag(new Tag("clause", ascCode.Get()));

    pTag->add_attribute("name", m_strName.Get());

    parent.add_tag(pTag);
}
开发者ID:bitcredit-currency,项目名称:opentxs,代码行数:15,代码来源:OTClause.cpp

示例9: GetPrototoken

bool OTToken::GetPrototoken(OTASCIIArmor & ascPrototoken, int nTokenIndex)
{

	// out of bounds. For a count 10 element array, index 10 is out of bounds.
	// thus if attempted index is equal or larger to the count, out of bounds.
	if (nTokenIndex >= m_nTokenCount)
	{
		return false;
	}
//	OTLog::vError("DEBUG OTToken::GetPrototoken. nTokenIndex is %d. m_nTokenCount is %d\n------------------------\n",
//			nTokenIndex, m_nTokenCount);
	
	// loop through the items that make up this transaction and print them out here, base64-encoded, of course.
	OTASCIIArmor * pPrototoken = NULL;
	
	for (mapOfPrototokens::iterator ii = m_mapPublic.begin(); ii != m_mapPublic.end(); ++ii)
	{
		pPrototoken = (*ii).second;
		
		OT_ASSERT(NULL != pPrototoken);
		
		const bool bSuccess = (nTokenIndex == (*ii).first);
		
//		OTLog::vError("DEBUG OTToken::GetPrototoken ABOUT TO ENTER, index: %d\n", nTokenIndex);
		
		if (bSuccess)
		{
			ascPrototoken.Set(*pPrototoken);
//			OTLog::vError("DEBUG OTToken::GetPrototoken INNER SANCTUM\n PROTOKEN:"
//						"\n-----------%s-----------\n", ascPrototoken.Get());
			return true;
		}
	}
	return false;	
}
开发者ID:batouzo,项目名称:Open-Transactions,代码行数:35,代码来源:OTToken.cpp

示例10: strID

bool OTServerContract::SaveContractWallet(OTString & strContents) const
{
	const OTString strID(m_ID);
	OTASCIIArmor   ascName;
	
	if (m_strName.Exists()) // name is in the clear in memory, and base64 in storage.
	{
		ascName.SetString(m_strName, false); // linebreaks == false
	}
	strContents.Concatenate("<notaryProvider name=\"%s\"\n"
							" serverID=\"%s\" />\n\n",
							m_strName.Exists() ? ascName.Get() : "",
							strID.Get());
	
	return true;
}
开发者ID:1manStartup,项目名称:Open-Transactions,代码行数:16,代码来源:OTServerContract.cpp

示例11: GetPrivatePrototoken

bool OTToken::GetPrivatePrototoken(OTASCIIArmor & ascPrototoken, int nTokenIndex)
{
	// out of bounds. For a count 10 element array, index 10 is out of bounds.
	// thus if attempted index is equal or larger to the count, out of bounds.
	if (nTokenIndex >= m_nTokenCount)
	{
		return false;
	}
	
	// loop through the items that make up this transaction and print them out here, base64-encoded, of course.
	OTASCIIArmor * pPrototoken = NULL;
	
	for (mapOfPrototokens::iterator ii = m_mapPrivate.begin(); ii != m_mapPrivate.end(); ++ii)
	{
		pPrototoken = (*ii).second;
		
		OT_ASSERT(NULL != pPrototoken);
		
		const bool bSuccess = (nTokenIndex == (*ii).first);
		
		if (bSuccess)
		{
			ascPrototoken.Set(*pPrototoken);
			return true;
		}
	}
	return false;	
}
开发者ID:batouzo,项目名称:Open-Transactions,代码行数:28,代码来源:OTToken.cpp

示例12: tag

void OTMasterkey::UpdateContents()
{
    m_xmlUnsigned.Release();

    Tag tag("masterCredential");

    // a hash of the nymIDSource
    tag.add_attribute("nymID", GetNymID().Get());

    if (GetNymIDSource().Exists()) {
        OTASCIIArmor ascSource;
        ascSource.SetString(GetNymIDSource()); // A nym should always
                                               // verify through its own
                                               // source. (Whatever that
                                               // may be.)
        tag.add_tag("nymIDSource", ascSource.Get());
    }

    // PUBLIC INFO
    //
    //  if (OTSubcredential::credPublicInfo == m_StoreAs)   // PUBLIC INFO
    // (Always save this in every state.)
    {
        UpdatePublicContentsToTag(tag);
    }

    // PRIVATE INFO
    //
    // If we're saving the private credential info...
    //
    if (OTSubcredential::credPrivateInfo == m_StoreAs) // PRIVATE INFO
    {
        UpdatePublicCredentialToTag(tag);
        UpdatePrivateContentsToTag(tag);
    }
    // -------------------------------------------------
    std::string str_result;
    tag.output(str_result);

    m_xmlUnsigned.Concatenate("%s", str_result.c_str());

    m_StoreAs = OTSubcredential::credPrivateInfo; // <=== SET IT BACK TO DEFAULT
                                                  // BEHAVIOR. Any other state
                                                  // processes ONCE, and then
                                                  // goes back to this again.
}
开发者ID:yamamushi,项目名称:opentxs,代码行数:46,代码来源:OTMasterkey.cpp

示例13: GetSize

// Envelope retrieved from payload.
bool OTPayload::GetEnvelope(OTEnvelope & theEnvelope) const
{
	// validate checksum
	uint32_t lSize = GetSize();
	uint32_t lIndex = lSize-2; // the index to where the NULL terminator SHOULD be if they
						  // sent us a base64-encoded string, containing an encrypted message. (which we expect...)

	// (lSize-1 would be the location of the checksum at the end.)
	if (0 == lSize)
		return false;

	if (IsChecksumValid((OT_BYTE*)GetPointer(), (uint32_t)lSize))
	{
		// We add the null-terminator ourselves at this point, for security reasons,
		// since we will process the data, soon after this function, as a string.
		((OT_BYTE *)GetPointer())[lIndex] = 0;

		theEnvelope.m_dataContents.Release();

		OTASCIIArmor theArmor;
		// Why is this safe, where I cast the Payload data pointer as
		// a char * and tell the data object to set itself from that?
		// Because (1) I just validated the checksum, and
		// (2) There place where the NULL should be, I set to 0, by hand,
		// just above 2 lines. So when this set operation occurs, the
		// farthest it will go is to that 0.
		theArmor.Set((const char *)GetPointer());

		// Todo NOTE: If I ever want to process bookends here instead of assuming they aren't there,
		// IT'S VERY EASY!! All I have to do is call theArmor.LoadFromString instead of theArmor.Set.

		// Now the ascii-armored string that was sent across is decoded back to binary into the
		// Envelope object.
		theEnvelope.SetAsciiArmoredData(theArmor);
		return true;
	}
	else
    {
		OTLog::Error("Invalid Checksum in OTPayload::GetEnvelope\n");
		return false;
	}
}
开发者ID:Guratri,项目名称:Open-Transactions,代码行数:43,代码来源:OTPayload.cpp

示例14:

OTCachedKey::OTCachedKey(const OTASCIIArmor & ascCachedKey) :
    m_pThread(NULL),
    m_nTimeoutSeconds(OTCachedKey::It()->GetTimeoutSeconds()),
    m_pMasterPassword(NULL), // This is created in GetMasterPassword, and destroyed by a timer thread sometime soon after. 
    m_bUse_System_Keyring(OTCachedKey::It()->IsUsingSystemKeyring()), // this master key instance will decide to use the system keyring based on what the global master key instance is set to do. (So we get the same settings from config file, etc.)
    m_pSymmetricKey(NULL),   // OTServer OR OTWallet owns this key, and sets this pointer. It's the encrypted form of s_pMasterPassword.
    m_bPaused(false)
{
    OT_ASSERT(ascCachedKey.Exists());
    this->SetCachedKey(ascCachedKey);
}
开发者ID:9cat,项目名称:Open-Transactions,代码行数:11,代码来源:OTCachedKey.cpp

示例15: strID

bool AssetContract::SaveContractWallet(Tag& parent) const
{
    const String strID(m_ID);

    // Name is in the clear in memory,
    // and base64 in storage.
    OTASCIIArmor ascName;
    if (m_strName.Exists()) {
        ascName.SetString(m_strName, false); // linebreaks == false
    }

    TagPtr pTag(new Tag("assetType"));

    pTag->add_attribute("name", m_strName.Exists() ? ascName.Get() : "");
    pTag->add_attribute("instrumentDefinitionID", strID.Get());

    parent.add_tag(pTag);

    return true;
}
开发者ID:bitcredit-currency,项目名称:opentxs,代码行数:20,代码来源:AssetContract.cpp


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