UCommon
ucommon::Digest Class Reference

A cryptographic digest class. More...

#include <secure.h>

Public Member Functions

 Digest (const char *type)
 
secure::keybytes key (void)
 
 operator bool () const
 
 operator secure::string ()
 
bool operator! () const
 
secure::string operator* ()
 
bool operator*= (const char *text)
 
bool operator+= (const char *text)
 
Digestoperator<< (const char *str)
 
Digestoperator<< (const PrintProtocol &p)
 
Digestoperator<< (int16_t value)
 
Digestoperator<< (int32_t value)
 
Digestoperator= (const char *id)
 
bool put (const void *memory, size_t size)
 
bool puts (const char *str)
 
void recycle (bool binary=false)
 Finalize and recycle current digest to start a new digest.
 
void reset (void)
 Reset and restart digest object.
 
void set (const char *id)
 
unsigned size () const
 
secure::string str (void)
 

Static Public Member Functions

static bool has (const char *name)
 Test to see if a specific digest type is supported.
 
static secure::string md5 (const char *text)
 Shortcut for short md5 digests if supported...
 
static secure::keybytes md5 (const uint8_t *mem, size_t size)
 
static secure::string sha1 (const char *text)
 
static secure::keybytes sha1 (const uint8_t *mem, size_t size)
 
static secure::string sha256 (const char *text)
 
static secure::keybytes sha256 (const uint8_t *mem, size_t size)
 
static secure::string sha384 (const char *text)
 
static secure::keybytes sha384 (const uint8_t *mem, size_t size)
 
static secure::string uuid (const char *name, const uint8_t *ns=NULL)
 

Protected Member Functions

const uint8_t * get (void)
 
void release (void)
 

Detailed Description

A cryptographic digest class.

This class can support md5 digests, sha1, sha256, etc, depending on what the underlying library supports. The hash class accumulates the hash in the object.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org
Examples
digest.cpp.

Definition at line 509 of file secure.h.

Member Function Documentation

◆ has()

static bool ucommon::Digest::has ( const char * name)
static

Test to see if a specific digest type is supported.

Parameters
nameof digest we want to check.
Returns
true if supported, false if not.

◆ md5()

static secure::string ucommon::Digest::md5 ( const char * text)
static

Shortcut for short md5 digests if supported...

Parameters
textto create a digest for.
Returns
digest string.

◆ operator bool()

ucommon::Digest::operator bool ( ) const
inline

Definition at line 602 of file secure.h.

◆ operator secure::string()

ucommon::Digest::operator secure::string ( )
inline

Definition at line 575 of file secure.h.

◆ operator!()

bool ucommon::Digest::operator! ( ) const
inline

Definition at line 598 of file secure.h.

◆ operator*()

secure::string ucommon::Digest::operator* ( )
inline

Definition at line 594 of file secure.h.

◆ operator*=()

bool ucommon::Digest::operator*= ( const char * text)
inline

Definition at line 586 of file secure.h.

◆ operator+=()

bool ucommon::Digest::operator+= ( const char * text)
inline

Definition at line 590 of file secure.h.

◆ operator<<() [1/4]

Digest & ucommon::Digest::operator<< ( const char * str)
inline

Definition at line 541 of file secure.h.

◆ operator<<() [2/4]

Digest & ucommon::Digest::operator<< ( const PrintProtocol & p)
inline

Definition at line 558 of file secure.h.

◆ operator<<() [3/4]

Digest & ucommon::Digest::operator<< ( int16_t value)
inline

Definition at line 546 of file secure.h.

◆ operator<<() [4/4]

Digest & ucommon::Digest::operator<< ( int32_t value)
inline

Definition at line 552 of file secure.h.

◆ operator=()

Digest & ucommon::Digest::operator= ( const char * id)
inline

Definition at line 581 of file secure.h.

◆ puts()

bool ucommon::Digest::puts ( const char * str)
inline
Examples
digest.cpp.

Definition at line 537 of file secure.h.

◆ recycle()

void ucommon::Digest::recycle ( bool binary = false)

Finalize and recycle current digest to start a new digest.

Parameters
binarydigest used rather than text if true.

◆ size()

unsigned ucommon::Digest::size ( ) const
inline

Definition at line 567 of file secure.h.

Field Documentation

◆ hashid

int ucommon::Digest::hashid

Definition at line 516 of file secure.h.

◆ hashtype

const void* ucommon::Digest::hashtype

Definition at line 515 of file secure.h.


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