libzypp
13.10.6
|
Compute Message Digests (MD5, SHA1 etc) More...
#include <Digest.h>
Classes | |
class | P |
Public Member Functions | |
Digest () | |
~Digest () | |
bool | create (const std::string &name) |
initialize creation of a new message digest More... | |
const std::string & | name () |
get the name of the current digest algorithm More... | |
bool | update (const char *bytes, size_t len) |
feed data into digest computation algorithm More... | |
std::string | digest () |
get hex string representation of the digest More... | |
std::vector< unsigned char > | digestVector () |
get vector of unsigned char representation of the digest More... | |
bool | reset () |
reset internal digest state More... | |
Static Public Member Functions | |
static std::string | digest (const std::string &name, std::istream &is, size_t bufsize=4096) |
compute digest of a stream. More... | |
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 More... | |
static const std::string & | sha1 () |
sha1 More... | |
static const std::string & | sha256 () |
sha256 More... | |
Private Member Functions | |
Digest (const Digest &d) | |
const Digest & | operator= (const Digest &d) |
Private Attributes | |
P * | _dp |
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
|
private |
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
name | name of the message digest algorithm. |
const std::string & zypp::Digest::name | ( | ) |
bool zypp::Digest::update | ( | const char * | bytes, |
size_t | len | ||
) |
std::string zypp::Digest::digest | ( | ) |
std::vector< unsigned char > zypp::Digest::digestVector | ( | ) |
bool zypp::Digest::reset | ( | ) |
|
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
name | name of the digest algorithm, |
is | an input stream to get the data from |
bufsize | size of the buffer used for update(). Be careful, this is on the stack. |
|
static |