本文整理汇总了C++中DataFile::calcDigest方法的典型用法代码示例。如果您正苦于以下问题:C++ DataFile::calcDigest方法的具体用法?C++ DataFile::calcDigest怎么用?C++ DataFile::calcDigest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataFile
的用法示例。
在下文中一共展示了DataFile::calcDigest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getFileDigest
QByteArray DigiDoc::getFileDigest( unsigned int i ) const
{
if( !checkDoc() || i >= b->dataFiles().size() )
return QByteArray();
try
{
DataFile file = b->dataFiles().at( i );
return fromVector(file.calcDigest("http://www.w3.org/2001/04/xmlenc#sha256"));
}
catch( const Exception & ) {}
return QByteArray();
}
示例2: d
BOOST_AUTO_TEST_CASE_TEMPLATE(document, Doc, DocTypes)
{
unique_ptr<Doc> d(new Doc);
BOOST_CHECK_THROW(d->removeDataFile(0U), Exception);
// Add first Document
BOOST_CHECK_NO_THROW(d->addDataFile("test1.txt", "file1"));
BOOST_CHECK_EQUAL(d->dataFiles().size(), 1U);
if(!d->dataFiles().empty())
{
DataFile doc1 = d->dataFiles().front();
if(d->mediaType() == DDoc::TYPE)
BOOST_CHECK_EQUAL(doc1.id(), "D0");
BOOST_CHECK_EQUAL(doc1.fileName(), "test1.txt");
BOOST_CHECK_EQUAL(doc1.mediaType(), "file1");
}
// Add second Document
BOOST_CHECK_NO_THROW(d->addDataFile("test2.bin", "file2"));
BOOST_CHECK_EQUAL(d->dataFiles().size(), 2U);
if(!d->dataFiles().empty())
{
DataFile doc2 = d->dataFiles().back();
if(d->mediaType() == DDoc::TYPE)
BOOST_CHECK_EQUAL(doc2.id(), "D1");
BOOST_CHECK_EQUAL(doc2.fileName(), "test2.bin");
BOOST_CHECK_EQUAL(doc2.mediaType(), "file2");
}
// Remove first Document
BOOST_CHECK_NO_THROW(d->removeDataFile(0U));
BOOST_CHECK_EQUAL(d->dataFiles().size(), 1U);
if(!d->dataFiles().empty())
{
DataFile doc3 = d->dataFiles().front();
if(d->mediaType() == DDoc::TYPE)
BOOST_CHECK_EQUAL(doc3.id(), "D1");
BOOST_CHECK_EQUAL(doc3.fileName(), "test2.bin");
BOOST_CHECK_EQUAL(doc3.mediaType(), "file2");
}
// Remove second Document
BOOST_CHECK_NO_THROW(d->removeDataFile(0U));
BOOST_CHECK_EQUAL(d->dataFiles().size(), 0U);
if(d->mediaType() == DDoc::TYPE)
return;
d.reset(new Doc("test." + Doc::EXT));
DataFile data = d->dataFiles().front();
BOOST_CHECK_NO_THROW(data.saveAs("test1.tmp"));
unsigned char sha1[] = {
0x1B, 0xE1, 0x68, 0xFF, 0x83, 0x7F, 0x04, 0x3B, 0xDE, 0x17,
0xC0, 0x31, 0x43, 0x41, 0xC8, 0x42, 0x71, 0x04, 0x7B, 0x31
};
unsigned char sha224[] = {
0xD7, 0x60, 0x41, 0x11, 0x2E, 0x34, 0x3B, 0x2B, 0xDC, 0x14,
0xD4, 0x39, 0x34, 0xE5, 0xAE, 0xD7, 0xAB, 0xF9, 0x01, 0x92,
0xC6, 0x54, 0x3B, 0xDF, 0x2A, 0xE4, 0xF8, 0x1B
};
unsigned char sha256[] = {
0xA8, 0x83, 0xDA, 0xFC, 0x48, 0x0D, 0x46, 0x6E, 0xE0, 0x4E,
0x0D, 0x6D, 0xA9, 0x86, 0xBD, 0x78, 0xEB, 0x1F, 0xDD, 0x21,
0x78, 0xD0, 0x46, 0x93, 0x72, 0x3D, 0xA3, 0xA8, 0xF9, 0x5D,
0x42, 0xF4
};
unsigned char sha384[] = {
0x63, 0x7E, 0x2E, 0xDD, 0x55, 0x55, 0x70, 0xED, 0xA9, 0x66,
0xD9, 0x9D, 0x4E, 0x77, 0xD9, 0xFB, 0xB3, 0xAA, 0xB8, 0x4A,
0x49, 0x8F, 0xF5, 0x5A, 0xC2, 0x1B, 0x96, 0x3C, 0x1E, 0x05,
0xC2, 0xAD, 0xDF, 0xB5, 0xC1, 0x5C, 0xD2, 0x07, 0x1E, 0x7E,
0xDD, 0x47, 0x35, 0x9D, 0x78, 0x79, 0x41, 0xD3
};
unsigned char sha512[] = {
0x79, 0x85, 0x55, 0x83, 0x70, 0xF0, 0xDE, 0x86, 0xA8, 0x64,
0xE0, 0x05, 0x0A, 0xFD, 0xF4, 0x5D, 0x70, 0x29, 0xB8, 0x79,
0x8B, 0xCD, 0x72, 0xCD, 0xDB, 0xF7, 0x81, 0x32, 0x9F, 0x99,
0x38, 0x0E, 0x3F, 0x3B, 0x1A, 0xFD, 0xCA, 0x67, 0x65, 0xD8,
0x9F, 0xC3, 0x88, 0xB2, 0x13, 0xDF, 0x8F, 0x6A, 0x19, 0x3C,
0xFC, 0x56, 0xD4, 0xFF, 0x2E, 0xF6, 0xE0, 0xA9, 0x9B, 0xD8,
0x83, 0xA6, 0xD9, 0x8C
};
BOOST_CHECK_EQUAL(data.calcDigest("http://www.w3.org/2000/09/xmldsig#sha1"),
vector<unsigned char>(sha1, sha1 + sizeof(sha1)));
BOOST_CHECK_EQUAL(data.calcDigest("http://www.w3.org/2001/04/xmldsig-more#sha224"),
vector<unsigned char>(sha224, sha224 + sizeof(sha224)));
BOOST_CHECK_EQUAL(data.calcDigest("http://www.w3.org/2001/04/xmlenc#sha256"),
vector<unsigned char>(sha256, sha256 + sizeof(sha256)));
BOOST_CHECK_EQUAL(data.calcDigest("http://www.w3.org/2001/04/xmldsig-more#sha384"),
vector<unsigned char>(sha384, sha384 + sizeof(sha384)));
BOOST_CHECK_EQUAL(data.calcDigest("http://www.w3.org/2001/04/xmlenc#sha512"),
vector<unsigned char>(sha512, sha512 + sizeof(sha512)));
}