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


C++ OTPassword::setPassword方法代码示例

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


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

示例1: GetPassword

// The password will be stored here by the Java dialog, so that the C callback can retrieve it and pass it to OpenSSL
//
bool OTCaller::GetPassword(OTPassword & theOutput) const // Get the password....
{ 
	OTLog::Output(0, "OTCaller::GetPassword: FYI, returning password after invoking a (probably Java) password dialog.\n");
	
	theOutput.setPassword(m_Password.getPassword(), m_Password.getPasswordSize());
	
	return true; 
}
开发者ID:DocMerlin,项目名称:Open-Transactions,代码行数:10,代码来源:OTPassword.cpp

示例2: runTwo

void PasswordCallback::runTwo(const char * szDisplay, OTPassword & theOutput)
{
    theOutput.setPassword(m_passphrase.c_str(), m_passphrase.length());
}
开发者ID:ychaim,项目名称:otapi-js,代码行数:4,代码来源:passwordCallback.cpp

示例3: runOne

void PasswordCallback::runOne(const char * szDisplay, OTPassword & theOutput)
{
    theOutput.setPassword(m_passphrase.c_str(), m_passphrase.size());
}
开发者ID:ychaim,项目名称:otapi-js,代码行数:4,代码来源:passwordCallback.cpp

示例4: GetMasterPassword


//.........这里部分代码省略.........
				bReturnVal = true; // Success.
			}
			else // It didn't unlock with the one we found.
			{
				OTLog::vOutput(0, "%s: Unable to unlock master key using derived key found on system keyring.\n", szFunc);
				delete pDerivedKey;
				pDerivedKey = NULL;  // Below, this function checks pDerivedKey for NULL.
			}
		}
		else    // NOT found on keyring.
		{
			if (this->IsUsingSystemKeyring()) // We WERE using the keying, but we DIDN'T find the derived key.
				OTLog::vOutput(1, "%s: Unable to find derived key on system keyring.\n", szFunc);
			// (Otherwise if we WEREN'T using the system keyring, then of course we didn't find any derived key cached there.)
			delete pDerivedKey;
			pDerivedKey = NULL; // Below, this function checks pDerivedKey for NULL.

		}
	}
	// --------------------------------------------------    
	// NOT found on Keyring...
	//
	if (NULL == pDerivedKey) // Master key was not cached in OT, nor was it found in the system keychain.
	{                        // Therefore we HAVE to ask the user for a passphrase and decrypt it ourselves,
		// since we DO have an encrypted version of the key...

		// This time we DEFINITELY force the user input, since we already played our hand.
		// If the master key was still in memory we would have returned already, above.
		// Then we tried to find it on the keyring and we couldn't find it, so now we have
		// to actually ask the user to enter it.
		//

		std::string default_password(OT_DEFAULT_PASSWORD); // default password
		OTPassword passwordDefault; passwordDefault.zeroMemory(); passwordDefault.setPassword(default_password.c_str(),static_cast<int>(default_password.length()));

		OTPassword passUserInput;  passUserInput.zeroMemory(); // text mode.
		OTPasswordData  thePWData(str_display.c_str(), &passUserInput, this); // these pointers are only passed in the case where it's for a master key.
//      OTLog::vOutput(2, "*********Begin OTCachedKey::GetMasterPassword: Calling souped-up password cb...\n * *  * *  * *  * *  * ");
		// -----------------------------------------------------------------------


		// It's possible this is the first time this is happening, and the master key 
		// hasn't even been generated yet. In which case, we generate it here...
		//
		bool bGenerated = m_pSymmetricKey->IsGenerated();

		if (!bGenerated) // This Symmetric Key hasn't been generated before....
		{

			if (!OTAsymmetricKey::GetPasswordCallback()(NULL, 0, bVerifyTwice ? 1 : 0, static_cast<void *>(&thePWData)))
			{
				OTLog::vError("%s: Failed to get password from user!", __FUNCTION__);
				return false;
			}


			// If the length of the user supplied password is less than 4 characters long, we are going to use the default password!
			bool bUsingDefaultPassword = false;
			{
				if (4 > std::string(passUserInput.getPassword()).length())
				{
					OTLog::vOutput(0, "\n Password entered was less than 4 characters long! This is NOT secure!!\n"
						"... Assuming password is for testing only... setting to default password: %s \n",
						OT_DEFAULT_PASSWORD);
					bUsingDefaultPassword = true;
				}
开发者ID:9cat,项目名称:Open-Transactions,代码行数:67,代码来源:OTCachedKey.cpp


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