HashUtil Class Reference
[Utils]

#include <HashUtil.h>

List of all members.


Detailed Description

Helper class for computing SHA1 hashes. Requires openssl.

Definition at line 57 of file HashUtil.h.


Static Public Member Functions

static void computeSha1 (const std::string &buf, sha1 &r)
 computes the sha1 of buf, storing in r
static void computeSha1 (int buf, sha1 &r)
 computes the sha1 of buf, storing in r
static void computeSha1 (const void *buf, size_t size, sha1 &r)
 computes the sha1 of buf (with size size), storing in r
static void computeMD5 (const void *buf, size_t size, md5 &r)
 computes the md5 of buf (with size size), storing in r
static void computeFileSha1 (const std::string &filePath, sha1 &h, struct stat &sbuf, bool dostat=true, bool followlink=false) throw (FileException)
 computes the SHA1 of the contents of a file
static void computeFileMD5 (const std::string &filePath, md5 &h, struct stat &sbuf, bool dostat=true, bool followlink=false) throw (FileException)
 computes the MD5 of the contents of a file
static size_t compute32bit (const std::string &buf)
 computes a 32 bit hash of a string (using class hash_string)
static std::string compute32bitHex (const std::string &buf)
 returns a 32 bit hash of buf in hex
static void computeHash (const void *buf, size_t size, std::string &r, const EVP_MD *md)
static void computeFileHash (const std::string &path, std::string &h, struct stat &sbuf, bool dostat, bool followlink, const EVP_MD *md) throw (FileException)
static EVP_MD_CTX * initCTX (const EVP_MD *md)
static void finalizeCTX (EVP_MD_CTX *mdctx, std::string &r)
static void freeCTX (EVP_MD_CTX *mdctx)

Static Public Attributes

static const sha1 & NULL_HASH = HashUtil::nullHash()
 convenience sha1 object for the "null" hash

Member Function Documentation

void HashUtil::computeFileSha1 ( const std::string &  filePath,
sha1 &  h,
struct stat &  sbuf,
bool  dostat = true,
bool  followlink = false 
) throw (FileException) [static]

computes the SHA1 of the contents of a file

Parameters:
filePath the file to hash
h where to store the hash
sbuf where to storesthe result of a filesystem stat()
dostat whether to store the result of stat() in sbuf
followlink if filePath is a symlink, whether to hash the link contents (false-default), or the linked-to contents (true)

Definition at line 81 of file HashUtil.cc.

References computeFileHash().

void HashUtil::computeFileMD5 ( const std::string &  filePath,
md5 &  h,
struct stat &  sbuf,
bool  dostat = true,
bool  followlink = false 
) throw (FileException) [static]

computes the MD5 of the contents of a file

Parameters:
filePath the file to hash
h where to store the hash
sbuf where to storesthe result of a filesystem stat()
dostat whether to store the result of stat() in sbuf
followlink if filePath is a symlink, whether to hash the link contents (false-default), or the linked-to contents (true)

Definition at line 86 of file HashUtil.cc.

References computeFileHash().

void HashUtil::computeHash ( const void *  buf,
size_t  size,
std::string &  r,
const EVP_MD *  md 
) [static]

Todo:
JWA - please doc

Definition at line 113 of file HashUtil.cc.

References finalizeCTX(), and initCTX().

Referenced by computeFileHash().

void HashUtil::computeFileHash ( const std::string &  path,
std::string &  h,
struct stat &  sbuf,
bool  dostat,
bool  followlink,
const EVP_MD *  md 
) throw (FileException) [static]

Todo:
JWA - please doc

Definition at line 151 of file HashUtil.cc.

References ADD_SELECTORS, computeHash(), Log::endl, Log::err(), finalizeCTX(), freeCTX(), Util::getErrorString(), and initCTX().

Referenced by computeFileMD5(), and computeFileSha1().

EVP_MD_CTX * HashUtil::initCTX ( const EVP_MD *  md  )  [static]

Todo:
JWA - please doc

Definition at line 91 of file HashUtil.cc.

Referenced by computeFileHash(), and computeHash().

void HashUtil::finalizeCTX ( EVP_MD_CTX *  mdctx,
std::string &  r 
) [static]

Todo:
JWA - please doc

Definition at line 98 of file HashUtil.cc.

References freeCTX().

Referenced by computeFileHash(), and computeHash().

void HashUtil::freeCTX ( EVP_MD_CTX *  mdctx  )  [static]

Todo:
JWA - please doc

Definition at line 108 of file HashUtil.cc.

Referenced by computeFileHash(), and finalizeCTX().


The documentation for this class was generated from the following files:

Generated on Sat Oct 4 21:30:28 2008 for Mace Library by  doxygen 1.5.5