libMVRgdtf 40bc00a
A library for GDTF and MVR
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SHA256 Class Reference

compute SHA256 hash More...

#include <sha256.h>

Public Types

enum  { BlockSize = 512 / 8 , HashBytes = 32 }
 split into 64 byte blocks (=> 512 bits), hash is 32 bytes long More...
 

Public Member Functions

 SHA256 ()
 same as reset()
 
std::string operator() (const void *data, size_t numBytes)
 compute SHA256 of a memory block
 
std::string operator() (const std::string &text)
 compute SHA256 of a string, excluding final zero
 
void add (const void *data, size_t numBytes)
 add arbitrary number of bytes
 
std::string getHash ()
 return latest hash as 64 hex characters
 
void getHash (unsigned char buffer[HashBytes])
 return latest hash as bytes
 
void reset ()
 restart
 

Detailed Description

compute SHA256 hash

Usage: SHA256 sha256; std::string myHash = sha256("Hello World"); // std::string std::string myHash2 = sha256("How are you", 11); // arbitrary data, 11 bytes

or in a streaming fashion:

SHA256 sha256;
while (more data available)
  sha256.add(pointer to fresh data, number of new bytes);
std::string myHash3 = sha256.getHash();

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

split into 64 byte blocks (=> 512 bits), hash is 32 bytes long

Enumerator
BlockSize 
HashBytes 

Constructor & Destructor Documentation

◆ SHA256()

SHA256::SHA256 ( )

same as reset()

Member Function Documentation

◆ add()

void SHA256::add ( const void *  data,
size_t  numBytes 
)

add arbitrary number of bytes

◆ getHash() [1/2]

std::string SHA256::getHash ( )

return latest hash as 64 hex characters

◆ getHash() [2/2]

void SHA256::getHash ( unsigned char  buffer[HashBytes])

return latest hash as bytes

◆ operator()() [1/2]

std::string SHA256::operator() ( const std::string &  text)

compute SHA256 of a string, excluding final zero

◆ operator()() [2/2]

std::string SHA256::operator() ( const void *  data,
size_t  numBytes 
)

compute SHA256 of a memory block

◆ reset()

void SHA256::reset ( )

restart


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