本文整理汇总了C++中KviCString::padRight方法的典型用法代码示例。如果您正苦于以下问题:C++ KviCString::padRight方法的具体用法?C++ KviCString::padRight怎么用?C++ KviCString::padRight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KviCString
的用法示例。
在下文中一共展示了KviCString::padRight方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool KviRijndaelEngine::init(const char * encKey, int encKeyLen, const char * decKey, int decKeyLen)
{
if(m_pEncryptCipher)
{
delete m_pEncryptCipher;
m_pEncryptCipher = nullptr;
}
if(m_pDecryptCipher)
{
delete m_pDecryptCipher;
m_pDecryptCipher = nullptr;
}
if(encKey && (encKeyLen > 0))
{
if(!(decKey && (decKeyLen > 0)))
{
decKey = encKey;
decKeyLen = encKeyLen;
} // else all
}
else
{
// no encrypt key specified...
if(decKey && decKeyLen)
{
encKey = decKey;
encKeyLen = decKeyLen;
}
else
{
// both keys missing
setLastError(__tr2qs("Missing both encryption and decryption key: at least one is needed"));
return false;
}
}
KviCString szTmpEncryptKey = KviCString(encKey, encKeyLen);
KviCString szTmpDecryptKey = KviCString(decKey, decKeyLen);
m_bEncryptMode = CBC; // default mode
m_bDecryptMode = CBC; // default mode
if(kvi_strEqualCIN("ecb:", szTmpEncryptKey.ptr(), 4) && (szTmpEncryptKey.len() > 4))
{
szTmpEncryptKey.cutLeft(4);
m_bEncryptMode = ECB;
}
else if(kvi_strEqualCIN("old:", szTmpEncryptKey.ptr(), 4) && (szTmpEncryptKey.len() > 4))
{
szTmpEncryptKey.cutLeft(4);
m_bEncryptMode = OldCBC;
}
else if(kvi_strEqualCIN("cbc:", szTmpEncryptKey.ptr(), 4) && (szTmpEncryptKey.len() > 4))
{
szTmpEncryptKey.cutLeft(4);
}
if(kvi_strEqualCIN("ecb:", szTmpDecryptKey.ptr(), 4) && (szTmpDecryptKey.len() > 4))
{
szTmpDecryptKey.cutLeft(4);
m_bDecryptMode = ECB;
}
else if(kvi_strEqualCIN("old:", szTmpDecryptKey.ptr(), 4) && (szTmpDecryptKey.len() > 4))
{
szTmpDecryptKey.cutLeft(4);
m_bDecryptMode = OldCBC;
}
else if(kvi_strEqualCIN("cbc:", szTmpDecryptKey.ptr(), 4) && (szTmpDecryptKey.len() > 4))
{
szTmpDecryptKey.cutLeft(4);
}
int defLen = getKeyLen();
szTmpEncryptKey.padRight(defLen);
szTmpDecryptKey.padRight(defLen);
m_pEncryptCipher = new Rijndael();
int retVal = m_pEncryptCipher->init(
(m_bEncryptMode == ECB) ? Rijndael::ECB : Rijndael::CBC,
Rijndael::Encrypt,
(unsigned char *)szTmpEncryptKey.ptr(),
getKeyLenId());
if(retVal != RIJNDAEL_SUCCESS)
{
delete m_pEncryptCipher;
m_pEncryptCipher = nullptr;
setLastErrorFromRijndaelErrorCode(retVal);
return false;
}
m_pDecryptCipher = new Rijndael();
retVal = m_pDecryptCipher->init(
(m_bEncryptMode == ECB) ? Rijndael::ECB : Rijndael::CBC,
Rijndael::Decrypt,
(unsigned char *)szTmpDecryptKey.ptr(),
getKeyLenId());
if(retVal != RIJNDAEL_SUCCESS)
//.........这里部分代码省略.........