zypp::Digest Class Reference

Compute Message Digests (MD5, SHA1 etc). More...

#include <Digest.h>

List of all members.

Classes

class  P

Public Member Functions

 Digest ()
 ~Digest ()
bool create (const std::string &name)
 initialize creation of a new message digest
const std::string & name ()
 get the name of the current digest algorithm
bool update (const char *bytes, size_t len)
 feed data into digest computation algorithm
std::string digest ()
 get hex string representation of the digest

Static Public Member Functions

static std::string digest (const std::string &name, std::istream &is, size_t bufsize=4096)
 compute digest of a stream.
static std::string digest (const std::string &name, const std::string &input, size_t bufsize=4096)
Well known digest algorithm names.
static const std::string & md5 ()
 md5
static const std::string & sha1 ()
 sha1
static const std::string & sha256 ()
 sha256

Private Member Functions

 Digest (const Digest &d)
const Digestoperator= (const Digest &d)

Private Attributes

P_dp


Detailed Description

Compute Message Digests (MD5, SHA1 etc).

The computation works by initializing the algorithm using create(). This will construct an internal state. successive calls to update() deliver the data for which the digest is to be computed. After all data has been deliverd, a call to digest() finalizes the computation and returns the result

Definition at line 44 of file Digest.h.


Constructor & Destructor Documentation

zypp::Digest::Digest ( const Digest d  )  [private]

zypp::Digest::Digest (  ) 

Definition at line 127 of file Digest.cc.

zypp::Digest::~Digest (  ) 

Definition at line 131 of file Digest.cc.

References _dp.


Member Function Documentation

const Digest& zypp::Digest::operator= ( const Digest d  )  [private]

const std::string & zypp::Digest::md5 (  )  [static]

md5

Definition at line 41 of file Digest.cc.

const std::string & zypp::Digest::sha1 (  )  [static]

sha1

Definition at line 44 of file Digest.cc.

Referenced by zypp::RepoManager::makeStupidAlias().

const std::string & zypp::Digest::sha256 (  )  [static]

sha256

Definition at line 47 of file Digest.cc.

bool zypp::Digest::create ( const std::string &  name  ) 

initialize creation of a new message digest

Since openssl is used as backend you may use anything that openssl supports (see man 1 dgst). Common examples are md5 or sha1. sha1 should be preferred when creating digests to verify the authenticity of something.

successive calls to this funcion will destroy the internal state and reinit from scratch

Parameters:
name name of the message digest algorithm.
Returns:
whether an error occured

Definition at line 136 of file Digest.cc.

References _dp, zypp::Digest::P::cleanup(), zypp::Digest::P::initialized, zypp::Digest::P::maybeInit(), and zypp::Digest::P::name.

Referenced by digest().

const std::string & zypp::Digest::name (  ) 

get the name of the current digest algorithm

Definition at line 148 of file Digest.cc.

References _dp, and zypp::Digest::P::name.

bool zypp::Digest::update ( const char *  bytes,
size_t  len 
)

feed data into digest computation algorithm

Parameters:
bytes 
len 
Returns:
whether an error occured

Definition at line 177 of file Digest.cc.

References _dp, zypp::Digest::P::cleanup(), zypp::Digest::P::finalized, zypp::Digest::P::maybeInit(), and zypp::Digest::P::mdctx.

Referenced by digest().

std::string zypp::Digest::digest (  ) 

get hex string representation of the digest

this function will finalize the digest computation. calls to update after this function will start from scratch

Returns:
hex string representation of the digest

Definition at line 153 of file Digest.cc.

References _dp, zypp::Digest::P::finalized, zypp::Digest::P::maybeInit(), zypp::Digest::P::md_len, zypp::Digest::P::md_value, and zypp::Digest::P::mdctx.

Referenced by zypp::filesystem::checksum(), zypp::CheckSum::CheckSum(), digest(), zypp::RepoManager::makeStupidAlias(), and zypp::filesystem::md5sum().

std::string zypp::Digest::digest ( const std::string &  name,
std::istream &  is,
size_t  bufsize = 4096 
) [static]

compute digest of a stream.

convenience function

calls create, update and digest in one function. The data for the computation is read from the stream

Parameters:
name name of the digest algorithm,
See also:
create
Parameters:
is an input stream to get the data from
bufsize size of the buffer used for update(). Be careful, this is on the stack.
Returns:
the digest or empty on error

Definition at line 200 of file Digest.cc.

References create(), digest(), and update().

std::string zypp::Digest::digest ( const std::string &  name,
const std::string &  input,
size_t  bufsize = 4096 
) [static]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 224 of file Digest.cc.

References digest().


Member Data Documentation

P* zypp::Digest::_dp [private]

Definition at line 47 of file Digest.h.

Referenced by create(), digest(), name(), update(), and ~Digest().


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

doxygen