本文整理汇总了C++中DataPtr::getRawData方法的典型用法代码示例。如果您正苦于以下问题:C++ DataPtr::getRawData方法的具体用法?C++ DataPtr::getRawData怎么用?C++ DataPtr::getRawData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataPtr
的用法示例。
在下文中一共展示了DataPtr::getRawData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getWifiDecodeKey
KeyStorage::DecodeKey KeyStorage::getWifiDecodeKey(
const std::string& ssid,
const std::string& bssid)
{
DecodeKey result;
static Data salt1("MCeGNFxMgyswwJfn6zCf");
static Data salt2("MfcLVmEF95tF6Sa6627e");
static Data salt3("5aU3a9EmyuwyyTRss7wM");
DataPtr res = Data::create(salt1);
res += ssid;
res += salt2;
res += bssid;
res += salt3;
DataPtr hash = Hash::apply(res);
if(hash)
{
Data::ByteArr& raw = hash->getRawData();
if(raw.size() >= Protect::KEY_SIZE + Protect::IV_SIZE)
{
DataPtr key = Data::create(&raw[0], Protect::KEY_SIZE);
DataPtr iv = Data::create(&raw[0]+Protect::KEY_SIZE, Protect::IV_SIZE);
result.key = key;
result.iv = iv;
}
}
return result;
}
示例2: testEncryption
void testEncryption()
{
std::string plain_text = "The rooster crows at midnight!";
std::string key = "A16ByteKey......";
DataPtr iv = Data::create("IV6ByteKey......");
Data::ByteArr& iv_raw = iv->getRawData();
//iv_raw.resize(Protect::IV_SIZE, 0);
DataPtr enc = Protect::encodeIV(Data::create(plain_text),
Data::create(key),
iv);
DataPtr enc2 = Protect::encode(Data::create(plain_text),
Data::create(key));
log("Enc: "+Base64::encode(enc)->toString());
log("Enc2: "+Base64::encode(enc2)->toString());
DataPtr dec = Protect::decodeIV(enc, Data::create(key), iv);
DataPtr dec2 = Protect::decode(enc2, Data::create(key));
log("Dec: "+dec->toString());
log("Dec2: "+dec2->toString());
}