Hash.H File Reference

#include "Image/Image.H"
#include "Util/Assert.H"
#include "Util/Types.H"
#include <string>
Include dependency graph for Hash.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Digest< N >
 Template message digest class represting a digest with N bytes. More...

Functions

std::string digestFormatHelper (const byte *buf, unsigned int n)
 Helper function for Digest::format().
void digestScanHelper (const std::string &s, byte *buf, unsigned int n)
 Helper function for Digest::fromString().
Image hash digest functions

NOTE that these hash digest functions ARE NOT overloads -- that is, we don't have sha1sum() for Image<byte>, another sha1sum() for Image<float>, etc. That's because in the case of checksums, we want to be very clear that there shouldn't be any implicit conversions going on -- a checksum for an Image<byte> will be very different from the checksum for an Image<float> even if those two images contain logically identical pixels. To further avoid implicit conversions, the digest functions take a pointer, not a reference, to the Image object -- although there is an implicit conversion from Image<byte> to Image<float>, there is no conversion from Image<byte>* to Image<float>*.

NOTE also that these functions are NOT intended to be portable across machines with different endianness. However, the digests ARE reproducible across multiple runs on different machines with the same endianness.

In all of these functions, there is an optional void* parameter plus number of bytes, which, if non-null, will also be hashed into the digest. This affords the opportunity to hash some additional piece of information along with the image. For example, if you want to hash some integer 'x' along with an image, you could call md5byte(&img, &x, sizeof(int)).

Digest< 16 > md5byte (const Image< byte > *img, const void *extra=0, size_t nextra=0)
 Compute the 128-bit md5 digest of a byte image.
Digest< 16 > md5float (const Image< float > *img, const void *extra=0, size_t nextra=0)
 Compute the 128-bit md5 digest of a float image.
Digest< 16 > md5rgb (const Image< PixRGB< byte > > *img, const void *extra=0, size_t nextra=0)
 Compute the 128-bit md5 digest of an rgb image.
Digest< 20 > sha1byte (const Image< byte > *img, const void *extra=0, size_t nextra=0)
 Compute the 160-bit sha1 digest of a byte image.
Digest< 20 > sha1float (const Image< float > *img, const void *extra=0, size_t nextra=0)
 Compute the 160-bit sha1 digest of a float image.
Digest< 20 > sha1rgb (const Image< PixRGB< byte > > *img, const void *extra=0, size_t nextra=0)
 Compute the 160-bit sha1 digest of an rgb image.
Digest< 32 > sha256byte (const Image< byte > *img, const void *extra=0, size_t nextra=0)
 Compute the 256-bit sha2 digest of a byte image.
Digest< 32 > sha256float (const Image< float > *img, const void *extra=0, size_t nextra=0)
 Compute the 256-bit sha2 digest of a float image.
Digest< 32 > sha256rgb (const Image< PixRGB< byte > > *img, const void *extra=0, size_t nextra=0)
 Compute the 256-bit sha2 digest of an rgb image.

Detailed Description

hash/message-digest functions for Image objects

Definition in file Hash.H.


Function Documentation

std::string digestFormatHelper ( const byte buf,
unsigned int  n 
)

Helper function for Digest::format().

Definition at line 104 of file Hash.C.

Referenced by Digest< 16 >::asString().

void digestScanHelper ( const std::string s,
byte buf,
unsigned int  n 
)

Helper function for Digest::fromString().

Definition at line 117 of file Hash.C.

Referenced by Digest< 16 >::fromString().

Digest<16> md5byte ( const Image< byte > *  img,
const void *  extra = 0,
size_t  nextra = 0 
)

Compute the 128-bit md5 digest of a byte image.

Definition at line 159 of file Hash.C.

Digest<16> md5float ( const Image< float > *  img,
const void *  extra = 0,
size_t  nextra = 0 
)

Compute the 128-bit md5 digest of a float image.

Definition at line 162 of file Hash.C.

Digest<16> md5rgb ( const Image< PixRGB< byte > > *  img,
const void *  extra = 0,
size_t  nextra = 0 
)

Compute the 128-bit md5 digest of an rgb image.

Definition at line 165 of file Hash.C.

Digest<20> sha1byte ( const Image< byte > *  img,
const void *  extra = 0,
size_t  nextra = 0 
)

Compute the 160-bit sha1 digest of a byte image.

Definition at line 169 of file Hash.C.

Digest<20> sha1float ( const Image< float > *  img,
const void *  extra = 0,
size_t  nextra = 0 
)

Compute the 160-bit sha1 digest of a float image.

Definition at line 172 of file Hash.C.

Digest<20> sha1rgb ( const Image< PixRGB< byte > > *  img,
const void *  extra = 0,
size_t  nextra = 0 
)

Compute the 160-bit sha1 digest of an rgb image.

Definition at line 175 of file Hash.C.

Digest<32> sha256byte ( const Image< byte > *  img,
const void *  extra = 0,
size_t  nextra = 0 
)

Compute the 256-bit sha2 digest of a byte image.

Definition at line 179 of file Hash.C.

Digest<32> sha256float ( const Image< float > *  img,
const void *  extra = 0,
size_t  nextra = 0 
)

Compute the 256-bit sha2 digest of a float image.

Definition at line 182 of file Hash.C.

Digest<32> sha256rgb ( const Image< PixRGB< byte > > *  img,
const void *  extra = 0,
size_t  nextra = 0 
)

Compute the 256-bit sha2 digest of an rgb image.

Definition at line 185 of file Hash.C.

Generated on Sun May 8 08:42:41 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3