本文整理汇总了C++中DataPtr::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ DataPtr::toString方法的具体用法?C++ DataPtr::toString怎么用?C++ DataPtr::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataPtr
的用法示例。
在下文中一共展示了DataPtr::toString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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());
}
示例2: testData
void testData()
{
DataPtr dun = Data::create("hello-worldhello-worldhello-worldhello-worldhello-worldhello-worldhello-worldhello-worldhello-worldhello-worldhello-worldhello-world");
log(dun->toString());
DataPtr d = ZLib::compress(dun);
DataPtr base64 = Base64::encode(d);
if(base64)
{
log(base64->toString());
DataPtr dec = Base64::decode(base64);
log(ZLib::decompress(dec)->toString());
std::string dec_string = base64->toString();
if(dec)
log(dec_string);
dec_string[2] = '*';
DataPtr dec2 = Base64::decode(Data::create(dec_string));
if(dec2)
log("Dec ok");
else
log("Dec failed");
}
}