本文整理汇总了C++中SHA::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ SHA::reset方法的具体用法?C++ SHA::reset怎么用?C++ SHA::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SHA
的用法示例。
在下文中一共展示了SHA::reset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main( int /*argc*/, char** /*argv*/ )
{
int fail = 0;
std::string name;
SHA sha;
// -------
name = "empty string";
sha.feed( "" );
sha.finalize();
if( sha.hex() != "da39a3ee5e6b4b0d3255bfef95601890afd80709" )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
sha.reset();
// -------
name = "The quick brown fox jumps over the lazy dog";
sha.feed( name );
sha.finalize();
if( sha.hex() != "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12" )
{
++fail;
fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), sha.hex().c_str() );
}
sha.reset();
// -------
name = "The quick brown fox jumps over the lazy cog";
sha.feed( name );
sha.finalize();
if( sha.hex() != "de9f2c7fd25e1b3afad3e85a0bd17d9b100db4b3" )
{
++fail;
fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), sha.hex().c_str() );
}
sha.reset();
// -------
name = "two-step";
sha.feed( "The quick brown fox " );
sha.feed( "jumps over the lazy dog" );
sha.finalize();
if( sha.hex() != "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12" )
{
++fail;
fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), sha.hex().c_str() );
}
sha.reset();
// -------
name = "54byte string";
sha.feed( std::string( 54, 'x' ) );
sha.finalize();
if( sha.hex() != "31045e7bb077ff8d188a776b196b980388735dbb" )
{
++fail;
fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), sha.hex().c_str() );
}
sha.reset();
// -------
name = "55byte string";
sha.feed( std::string( 55, 'x' ) );
sha.finalize();
if( sha.hex() != "cef734ba81a024479e09eb5a75b6ddae62e6abf1" )
{
++fail;
fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), sha.hex().c_str() );
}
sha.reset();
// -------
name = "56byte string";
sha.feed( std::string( 56, 'x' ) );
sha.finalize();
if( sha.hex() != "901305367c259952f4e7af8323f480d59f81335b" )
{
++fail;
fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), sha.hex().c_str() );
}
sha.reset();
// -------
name = "57byte string";
sha.feed( std::string( 57, 'x' ) );
sha.finalize();
if( sha.hex() != "025ecbd5d70f8fb3c5457cd96bab13fda305dc59" )
{
++fail;
fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), sha.hex().c_str() );
}
sha.reset();
// -------
name = "many-step";
sha.feed( "The" );
//.........这里部分代码省略.........