本文整理汇总了C++中MD5::final_hex方法的典型用法代码示例。如果您正苦于以下问题:C++ MD5::final_hex方法的具体用法?C++ MD5::final_hex怎么用?C++ MD5::final_hex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MD5
的用法示例。
在下文中一共展示了MD5::final_hex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST( Utils, MD5 )
{
MD5 checksum;
// abc
checksum.update("abc");
EXPECT_EQ( "900150983cd24fb0d6963f7d28e17f72", checksum.final_hex() );
// abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq
checksum.update("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq");
EXPECT_EQ( "8215ef0796a20bcaaae116d3876c664a", checksum.final_hex() );
// A million repetitions of 'a'.
for (int i = 0; i < 1000000/200; ++i)
{
checksum.update(
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
);
}
EXPECT_EQ( "7707d6ae4e027c70eea2a935c2296f21", checksum.final_hex() );
// No string
EXPECT_EQ( "d41d8cd98f00b204e9800998ecf8427e", checksum.final_hex());
// Empty string
checksum.update("");
EXPECT_EQ( "d41d8cd98f00b204e9800998ecf8427e", checksum.final_hex());
// Two concurrent checksum calculations
MD5 checksum1, checksum2;
checksum1.update("abc");
EXPECT_EQ( "900150983cd24fb0d6963f7d28e17f72", checksum1.final_hex());
EXPECT_EQ( "d41d8cd98f00b204e9800998ecf8427e", checksum2.final_hex());
}