Rudiments
Public Member Functions | List of all members
hash Class Referenceabstract

Inherits object.

Inherited by des, md5, sha1, and sha256.

Public Member Functions

 hash ()
 
virtual ~hash ()
 
virtual bool setSalt (const byte_t *salt, size_t size)
 
virtual const byte_t * getSalt ()
 
virtual size_t getSaltSize ()
 
virtual bool append (const byte_t *data, uint32_t size)
 
virtual const byte_t * getHash ()=0
 
virtual uint64_t getHashSize ()
 
virtual hasherror_t getError ()
 
virtual bool clear ()
 
virtual bool reset ()
 
- Public Member Functions inherited from object
virtual ~object ()
 

Detailed Description

The hash class defines an interface for hashing.

Constructor & Destructor Documentation

◆ hash()

hash::hash ( )

Creates an instance of the hash class.

◆ ~hash()

virtual hash::~hash ( )
virtual

Deletes this instance of the hash class.

Member Function Documentation

◆ append()

virtual bool hash::append ( const byte_t *  data,
uint32_t  size 
)
virtual

Appends "size" bytes of "data" to the data to be hashed. Returns true on success or false if an error occurred.

Reimplemented in sha256, sha1, and md5.

◆ clear()

virtual bool hash::clear ( )
virtual

Clears the current hash and any data that had previously been appended.

Does not clear the salt.

This implementation always returns true, but a child class may override this method to return false if something fails, and possibly set an error.

Reimplemented in sha256, sha1, and md5.

◆ getError()

virtual hasherror_t hash::getError ( )
virtual

Returns the most recent error.

Reimplemented in sha256, sha1, and md5.

◆ getHash()

virtual const byte_t* hash::getHash ( )
pure virtual

Returns the current hash on success or NULL if an error occurred. Note that the current hash will be an empty string if no data has been appended yet.

Implemented in sha256, sha1, md5, and des.

◆ getHashSize()

virtual uint64_t hash::getHashSize ( )
virtual

Returns the number of bytes in the hash.

Reimplemented in sha256, sha1, md5, and des.

◆ getSalt()

virtual const byte_t* hash::getSalt ( )
virtual

Returns the salt set by a previous call to setSalt() or NULL if no salt has been set.

◆ getSaltSize()

virtual size_t hash::getSaltSize ( )
virtual

Returns the number of bytes in the salt.

Reimplemented in des.

◆ reset()

virtual bool hash::reset ( )
virtual

Clears the current hash and any data that had previously been appended, and the salt.

This implementation always returns true, but a child class may override this method to return false if something fails, and possibly set an error.

◆ setSalt()

virtual bool hash::setSalt ( const byte_t *  salt,
size_t  size 
)
virtual

Sets the salt.