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


C++ Hash::update方法代码示例

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


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

示例1: write

 size_t write(const void *buf, size_t count)
 {
   // Hash, then write
   hash.update(buf, count);
   summed += count;
   return src->write(buf,count);
 }
开发者ID:korslund,项目名称:spread,代码行数:7,代码来源:hash_stream.hpp

示例2: sum

  /* Directly sum an entire stream. The stream is read in increments,
     to avoid loading large files into memory. You can specify the
     buffer size as the second parameter, the default is 16 Kb.

     The algorithm does not depend on size() for non-pointer streams.

     Pointer streams are hashed in one go, and do not advance the file
     pointer.

     Since the position of the file pointer after this operation
     depends on the type of stream given, it is considered undefined.
   */
  static Hash sum(Mangle::Stream::Stream &str, int bufsize = DEFSIZE)
  {
    assert(str.isReadable);

    // Is this a memory stream?
    if(str.hasPtr)
      {
        assert(str.hasSize);

        // Pointer streams makes life easy
        return Hash(str.getPtr(), str.size());
      }

    // No pointers today. Create a buffer and hash in increments.
    char *buf = new char[bufsize];

    Hash result;

    // We do not depend on the stream size, only on eof().
    while(!str.eof())
      {
        size_t num = str.read(buf, bufsize);

        // If we read less than expected, we should be at the
        // end of the stream
        assert(num == bufsize || (num < bufsize && str.eof()));

        // Hash the data
        result.update(buf, num);
      }

    // Clean up and return
    delete[] buf;
    return result.finish();
  }
开发者ID:korslund,项目名称:spread,代码行数:47,代码来源:hash_stream.hpp

示例3: read

 size_t read(void *buf, size_t count)
 {
   // Read, then hash
   size_t res = src->read(buf, count);
   // And make sure to only hash actual bytes read
   hash.update(buf, res);
   summed += res;
   return res;
 }
开发者ID:korslund,项目名称:spread,代码行数:9,代码来源:hash_stream.hpp

示例4:

		Hmac (const unsigned char* arg_key, size_t arg_key_len =KEY_LENGTH)
		{
			if (arg_key_len > Hash::BLOCK_LENGTH) {
				Hash::compute(key, Hash::BLOCK_LENGTH, arg_key, arg_key_len);
				key_len = Hash::LENGTH;
			} else {
				std::memcpy(key, arg_key, arg_key_len);
				key_len = arg_key_len;
			}

			unsigned char	k_ipad[Hash::BLOCK_LENGTH];
			std::memset(k_ipad, 0, Hash::BLOCK_LENGTH);
			std::memcpy(k_ipad, key, key_len);
			for (size_t i = 0; i < Hash::BLOCK_LENGTH; ++i) {
				k_ipad[i] ^= 0x36;
			}

			hash.update(k_ipad, Hash::BLOCK_LENGTH);
			explicit_memzero(k_ipad, Hash::BLOCK_LENGTH);
		}
开发者ID:AGWA,项目名称:batv-tools,代码行数:20,代码来源:hmac.hpp


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