Back to Index

The MaybeBoost Hash Library: Functions

The compute_digest Family

Defined in <boost/hash/compute_digest.hpp>

These are convenience functions for calculating the message digest of a single range of data. All versions take a HashAlgorithm model as an explicit template parameter and return the corresponding HashAlgorithm::digest_type. All the bits in the input range values are used (including the sign bit, if present).

There are multiple ways to provide the range:

Portability Note: Hashing values with compute_digest is portable if you ensure that the size in bits of the range iterator's value_type is the same on all machines. It's expected that most users will be hashing bytes on POSIX-compatible machines (where bytes are always 8 bits), and thus will have no portability issues.

Limitation: It is not possible to explicitly specify the number of bits to use from each value in the range when using compute_digest. The alternative is to use the StreamHash directly. This can still be done as an expression using code along the lines of the following:

typedef HashAlgorithm::stream_hash<N>::type shn;
shn::digest_type d = shn().update(b, e).end_message();

Previous: Classes Next: Concepts

Copyright Scott McMurray 2010

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at