当前位置: 首页>>代码示例>>C++>>正文


C++ SHA::finalize方法代码示例

本文整理汇总了C++中SHA::finalize方法的典型用法代码示例。如果您正苦于以下问题:C++ SHA::finalize方法的具体用法?C++ SHA::finalize怎么用?C++ SHA::finalize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SHA的用法示例。


在下文中一共展示了SHA::finalize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: s_saveVCard

void jAccount::s_saveVCard(VCard *vcard)
{
	QString hex = "";
	const VCard::Photo &photo = vcard->photo();
	if(!photo.binval.empty())
	{
		QByteArray data(photo.binval.c_str(),photo.binval.length());
		SHA sha;
		sha.feed(photo.binval);
		sha.finalize();
		hex = jProtocol::fromStd(sha.hex());
	}
	m_jabber_protocol->updateAvatarPresence(hex);
	m_jabber_protocol->storeVCard(vcard);
}
开发者ID:RankoR,项目名称:mqutim,代码行数:15,代码来源:jAccount.cpp

示例2: 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" );
//.........这里部分代码省略.........
开发者ID:PeterXu,项目名称:sipstack,代码行数:101,代码来源:sha_test.cpp

示例3: handleIqID

  bool NonSaslAuth::handleIqID( Stanza *stanza, int context )
  {
    switch( stanza->subtype() )
    {
      case StanzaIqError:
      {
        m_parent->setAuthed( false );
        m_parent->disconnect( ConnAuthenticationFailed );

        Tag *t = stanza->findChild( "error" );
        if( t )
        {
          if( t->hasChild( "conflict" ) || t->hasAttribute( "code", "409" ) )
            m_parent->setAuthFailure( NonSaslConflict );
          else if( t->hasChild( "not-acceptable" ) || t->hasAttribute( "code", "406" ) )
            m_parent->setAuthFailure( NonSaslNotAcceptable );
          else if( t->hasChild( "not-authorized" ) || t->hasAttribute( "code", "401" ) )
            m_parent->setAuthFailure( NonSaslNotAuthorized );
        }
        break;
      }
      case StanzaIqResult:
        switch( context )
        {
          case TRACK_REQUEST_AUTH_FIELDS:
          {
            const std::string& id = m_parent->getID();

            Tag *iq = new Tag( "iq" );
            iq->addAttribute( "id", id );
            iq->addAttribute( "type", "set" );
            Tag *query = new Tag( iq, "query" );
            query->addAttribute( "xmlns", XMLNS_AUTH );
            new Tag( query, "username", m_parent->jid().username() );
            new Tag( query, "resource", m_parent->jid().resource() );

            Tag *q = stanza->findChild( "query" );
            if( ( q->hasChild( "digest" ) ) && !m_sid.empty() )
            {
              SHA sha;
              sha.feed( m_sid );
              sha.feed( m_parent->password() );
              sha.finalize();
              new Tag( query, "digest", sha.hex() );
            }
            else
            {
              new Tag( query, "password", m_parent->password() );
            }

            m_parent->trackID( this, id, TRACK_SEND_AUTH );
            m_parent->send( iq );
            break;
          }
          case TRACK_SEND_AUTH:
            m_parent->setAuthed( true );
            m_parent->connected();
            break;
        }
        break;

      default:
        break;
    }
    return false;
  }
开发者ID:soubok,项目名称:libset,代码行数:66,代码来源:nonsaslauth.cpp


注:本文中的SHA::finalize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。