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


C++ SetKey函数代码示例

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


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

示例1: SetKey

void pawsKeySelectBox::SetText(const char * keyText)
{
    text = keyText;
    if (text.IsEmpty())
    {
        SetKey(0,0);
        return;
    }

    size_t spaceChar;
    while ((spaceChar = text.FindFirst(' ')) > 0)
        text.DeleteAt(spaceChar);

    utf32_char keyCode;
    utf32_char cookedCode;
    csKeyModifiers mods;

    if (!csInputDefinition::ParseKey(PawsManager::GetSingleton().GetEventNameRegistry (),
	  text, &keyCode, &cookedCode, &mods))
    {
        SetKey(0,0);
        return;
    }

    modifiers = 0;
    if (mods.modifiers[csKeyModifierTypeAlt] != 0)
        modifiers |= CSMASK_ALT;
    if (mods.modifiers[csKeyModifierTypeCtrl] != 0)
        modifiers |= CSMASK_CTRL;
    if (mods.modifiers[csKeyModifierTypeShift] != 0)
        modifiers |= CSMASK_SHIFT;

    SetKey(keyCode, modifiers);
}
开发者ID:garinh,项目名称:planeshift,代码行数:34,代码来源:pawskeyselectbox.cpp

示例2: main

int main()
{
	int i=0; 
	char MesHex[16]={0};         // 16个字符数组用于存放 64位16进制的密文
 	char MyKey[8]={0};           // 初始密钥 8字节*8
	char YourKey[8]={0};         // 输入的解密密钥 8字节*8
	char MyMessage[8]={0};       // 初始明文 
	
/*-----------------------------------------------*/

	printf("Welcome! Please input your Message(64 bit):\n");
	gets(MyMessage);            // 明文
	printf("Please input your Secret Key:\n");
	gets(MyKey);                // 密钥

	while(MyKey[i]!='\0')        // 计算密钥长度
	{
		i++;
	}

	while(i!=8)                  // 不是8 提示错误
	{
		printf("Please input a correct Secret Key!\n");
		gets(MyKey);
		i=0;
		while(MyKey[i]!='\0')    // 再次检测
		{
			i++;
		}
	}

	SetKey(MyKey);               // 设置密钥 得到子密钥Ki
	
	PlayDes(MesHex,MyMessage);   // 执行DES加密

	printf("Your Message is Encrypted!:\n");  // 信息已加密
	for(i=0;i<16;i++)           
	{
		printf("%c ",MesHex[i]);
	}
	printf("\n");
	printf("\n");
	
	printf("Please input your Secret Key to Deciphering:\n");  // 请输入密钥以解密
	gets(YourKey);                                         // 得到密钥
	SetKey(YourKey);                                       // 设置密钥

	KickDes(MyMessage,MesHex);                     // 解密输出到MyMessage
	
	printf("Deciphering Over !!:\n");                     // 解密结束
	for(i=0;i<8;i++)
	{
		printf("%c ",MyMessage[i]);
	}
	printf("\n");
	system("pause");
		
/*------------------------------------------------*/	
}
开发者ID:VaryJames,项目名称:Sample,代码行数:59,代码来源:main.c

示例3: SetKey

status_t
AESAlgorithm::SetCompleteKey(ThreadContext& context, const uint8* key,
	size_t keyLength)
{
	if (fMode == MODE_LRW)
		return SetKey(context, key + KEY_SIZE, KEY_SIZE);

	return SetKey(context, key, KEY_SIZE);
}
开发者ID:axeld,项目名称:driveencryption,代码行数:9,代码来源:crypt.cpp

示例4: key_

PublicKey::PublicKey(const byte* k, word32 s) : key_(0), sz_(0)
{
    if (s) {
        SetSize(s);
        SetKey(k);
    }
}
开发者ID:zhongliangkang,项目名称:mysql-5.6.6-labs-april-2012-sky,代码行数:7,代码来源:asn.cpp

示例5: while

//-------------------------------------------------------------------------------------------------
bool sdAnimUIntTrack::Load(Engine::Util::sdLuaReadUtil& kLuaStream)
{
	if (!kLuaStream.ReadData("TrackFlag", m_iFlags))
	{
		m_iFlags = IKey::E_KEY_FLAG_CONSTANT;
	}

	kLuaStream.BeginReadNode("Value");
	if (kLuaStream.IsNodeValid())
	{
		int t = kLuaStream.LoopReset();
		while (kLuaStream.LoopNext(t))
		{
			sdUIntKey kKey;
			kLuaStream.ReadData("Time",  kKey.m_fTime);
			kLuaStream.ReadData("Flags", kKey.m_iFlags);
			kLuaStream.ReadData("UInt",  kKey.m_uiValue);

			int iIndex = CreateKey(kKey.m_fTime);
			SetKey(iIndex, &kKey);

			kLuaStream.LoopInnerEnd();
		}
	}
	kLuaStream.EndReadNode();

	return true;
}
开发者ID:arundev,项目名称:dev-code,代码行数:29,代码来源:sdAnimUIntTrack.cpp

示例6: kKey

//-------------------------------------------------------------------------------------------------
void sdAnimUIntTrack::SetValue(float fTime, uint uiValue) 
{
	sdUIntKey kKey(fTime, IKey::E_KEY_FLAG_CONSTANT, uiValue);
	int iIndex = FindKey(fTime);
	if (iIndex == -1)
	{
		int iKeyNum = GetNumKeys();
		SetNumKeys(iKeyNum + 1);
		SetKey(iKeyNum, &kKey);
		SortKeys();
	}
	else
	{
		SetKey(iIndex, &kKey);
	}
}
开发者ID:arundev,项目名称:dev-code,代码行数:17,代码来源:sdAnimUIntTrack.cpp

示例7: derive_key

//! Use key + salt to encrypt the header, and write it to disk.
status_t
VolumeCryptContext::_WriteHeader(int fd, const uint8* key, uint32 keyLength,
	off_t headerOffset, uint8* buffer)
{
	uint8 diskKey[DISK_KEY_SIZE];
	derive_key(key, keyLength, buffer, PKCS5_SALT_SIZE, diskKey, DISK_KEY_SIZE);

	status_t status = Init(ALGORITHM_AES, MODE_XTS, diskKey, DISK_KEY_SIZE);
	if (status != B_OK)
		return status;

	true_crypt_header& header = *(true_crypt_header*)&buffer[PKCS5_SALT_SIZE];
	Encrypt((uint8*)&header, BLOCK_SIZE - PKCS5_SALT_SIZE);

	ssize_t bytesWritten = write_pos(fd, headerOffset, buffer, BLOCK_SIZE);
	if (bytesWritten < 0)
		return errno;

	// use the decrypted header to init the volume encryption

	Decrypt((uint8*)&header, BLOCK_SIZE - PKCS5_SALT_SIZE);
	SetKey(header.disk_key, sizeof(header.disk_key));

	return B_OK;
}
开发者ID:axeld,项目名称:driveencryption,代码行数:26,代码来源:crypt.cpp

示例8: _Uninit

status_t
CryptContext::Init(encryption_algorithm algorithm, encryption_mode mode,
	const uint8* key, size_t keyLength)
{
	_Uninit();

	ThreadContext threadContext;

	fAlgorithm = create_algorithm(algorithm);
	if (fAlgorithm == NULL)
		return B_NO_MEMORY;

	status_t status = fAlgorithm->Init(threadContext);
	if (status != B_OK)
		return status;

	fMode = create_mode(mode);
	if (fMode == NULL)
		return B_NO_MEMORY;

	status = fMode->Init(threadContext, fAlgorithm);
	if (status != B_OK)
		return status;

	fThreadContexts = new(std::nothrow) ThreadContext*[sThreadCount];
	if (fThreadContexts == NULL)
		return B_NO_MEMORY;

	for (int32 i = 0; i < sThreadCount; i++) {
		fThreadContexts[i] = new ThreadContext(threadContext);
	}

	return SetKey(key, keyLength);
}
开发者ID:axeld,项目名称:driveencryption,代码行数:34,代码来源:crypt.cpp

示例9: m_TrackId

/*----------------------------------------------------------------------
|       AP4_IsmaKeyMap::KeyEntry::KeyEntry
+---------------------------------------------------------------------*/
AP4_IsmaKeyMap::KeyEntry::KeyEntry(AP4_UI32        track_id, 
                                   const AP4_UI08* key, 
                                   const AP4_UI08* salt /* = NULL */) :
    m_TrackId(track_id)
{
    SetKey(key, salt);
}
开发者ID:AeonAxan,项目名称:mpc-hc,代码行数:10,代码来源:Ap4IsmaCryp.cpp

示例10: DesCode

ULONG DesCode( void *Out, const void *In, ULONG Length, const void *Key, ULONG KeyLength, ULONG Type )
{
    register int Iter;
    register int Count;
    ULONG Is3DES;
    ULONG Left;
    const UCHAR *UKey;
    register UCHAR *UOut;
    register const UCHAR *UIn;
    DES_SUBKEY SubKey[2]; /* 16 loop sub key */

    if ( Out == NULL || In == NULL || Key == NULL || Length == 0 )
        return FALSE;

    UKey = ( const UCHAR* )Key;
    SetKey( SubKey, &Is3DES, UKey, KeyLength );

    Left = Length & 7;
    Length &= ~7;
    if ( !Is3DES )
    {
        /* 1DES */
        UOut = ( UCHAR* )Out;
        UIn = ( const UCHAR* )In;
        for ( Iter = 0, Count = Length >> 3; Iter < Count; Iter++, UOut += 8, UIn += 8 )
            DES( UOut, UIn, &SubKey[0], Type );
        while ( Left )
        {
            *UOut = ( UCHAR ) ( *UIn ^ DEFAULT_XOR ^ UKey[Left % KeyLength] );
            UIn++;
            UOut++;
            Left--;
        }
    }
开发者ID:Skull-Li,项目名称:dezend,代码行数:34,代码来源:Encode.c

示例11: SetKey

bool SecMsgCrypter::SetKey(const std::vector<uint8_t> &vchNewKey, const uint8_t *chNewIV)
{
    if (vchNewKey.size() != SMSG_CRYPTO_KEY_SIZE)
        return false;

    return SetKey(&vchNewKey[0], chNewIV);
};
开发者ID:CryptoRekt,项目名称:VERGE,代码行数:7,代码来源:crypter.cpp

示例12: SetKey

void CServerDesc::Serialize( CAr & ar )
{
	if( ar.IsStoring() )
	{
		ar << m_uKey;
		ar << (short)m_lspJurisdiction.size();
		for( list<CJurisdiction*>::iterator i = m_lspJurisdiction.begin(); i != m_lspJurisdiction.end(); ++i )
		{
			ar << (*i)->m_dwWorldID;
			ar << (*i)->m_rect;
			ar << (*i)->m_wLeft;
			ar << (*i)->m_wRight;
		}
		ar.WriteString( m_szAddr );
	}
	else
	{
		u_long uKey;
		ar >> uKey;
		SetKey( uKey );
		short nSize;
		ar >> nSize;
		for( int i =0; i < nSize; i++ )
		{
			CJurisdiction* pJurisdiction	= new CJurisdiction;
			ar >> pJurisdiction->m_dwWorldID;
			ar >> pJurisdiction->m_rect;
			ar >> pJurisdiction->m_wLeft;
			ar >> pJurisdiction->m_wRight;
			m_lspJurisdiction.push_back( pJurisdiction );
		}
		ar.ReadString( m_szAddr );
	}
}
开发者ID:KerwinMa,项目名称:AerothFlyffSource,代码行数:34,代码来源:serverdesc.cpp

示例13: iIOCtl

int __stdcall iIOCtl(int cmd, void *data)
{
	int result = 0;


	switch(cmd)
	{
	case 0:
		ChangeCard();
		break;

	case 1:
		InitCard();
		break;

	case 2:
		SetKey((struct CreateKeyInfoS *)data);
		break;

	case 3:
		ChangeVirtualFile((char *)data);
		break;

	default:
		break;
	}

	return result;
}
开发者ID:iceleeyo,项目名称:CardProject,代码行数:29,代码来源:vcard.c

示例14: SetKey

CStringTable::CStringTable(WORD wLang, WORD wCodePage)
{
	CString strKey;
	strKey.Format(_T("%04x%04x"), wLang, wCodePage);

	SetKey(strKey);
}
开发者ID:JohnWilliam1988,项目名称:TCIDE,代码行数:7,代码来源:StringTable.cpp

示例15: Reset

CChan::CChan(const CString& sName, CIRCNetwork* pNetwork, bool bInConfig, CConfig *pConfig) {
	m_sName = sName.Token(0);
	m_sKey = sName.Token(1);
	m_pNetwork = pNetwork;

	if (!m_pNetwork->IsChan(m_sName)) {
		m_sName = "#" + m_sName;
	}

	m_bInConfig = bInConfig;
	m_Nick.SetNetwork(m_pNetwork);
	m_bDetached = false;
	m_uBufferCount = m_pNetwork->GetUser()->GetBufferCount();
	m_bKeepBuffer = m_pNetwork->GetUser()->KeepBuffer();
	m_bDisabled = false;
	Reset();

	if (pConfig) {
		CString sValue;
		if (pConfig->FindStringEntry("buffer", sValue))
			SetBufferCount(sValue.ToUInt(), true);
		if (pConfig->FindStringEntry("keepbuffer", sValue))
			SetKeepBuffer(sValue.ToBool());
		if (pConfig->FindStringEntry("detached", sValue))
			SetDetached(sValue.ToBool());
		if (pConfig->FindStringEntry("autocycle", sValue))
			if (sValue.Equals("true"))
				CUtils::PrintError("WARNING: AutoCycle has been removed, instead try -> LoadModule = autocycle " + sName);
		if (pConfig->FindStringEntry("key", sValue))
			SetKey(sValue);
		if (pConfig->FindStringEntry("modes", sValue))
			SetDefaultModes(sValue);
	}
}
开发者ID:jimloco,项目名称:znc,代码行数:34,代码来源:Chan.cpp


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