tlx

SHA-256 processor without external dependencies. More...

#include <sha256.hpp>

Public Member Functions

 SHA256 ()
 construct empty object. More...
 
 SHA256 (const void *data, uint32_t size)
 construct context and process data range More...
 
 SHA256 (const std::string &str)
 construct context and process string More...
 
void process (const void *data, uint32_t size)
 process more data More...
 
void process (const std::string &str)
 process more data More...
 
void finalize (void *digest)
 finalize computation and output 32 byte (256 bit) digest More...
 
std::string digest ()
 finalize computation and return 32 byte (256 bit) digest More...
 
std::string digest_hex ()
 finalize computation and return 32 byte (256 bit) digest hex encoded More...
 
std::string digest_hex_uc ()
 finalize computation and return 32 byte (256 bit) digest upper-case hex More...
 

Static Public Attributes

static constexpr size_t kDigestLength
 digest length in bytes More...
 

Private Attributes

uint64_t length_
 
uint32_t state_ [8]
 
uint32_t curlen_
 
uint8_t buf_ [64]
 

Detailed Description

SHA-256 processor without external dependencies.

Definition at line 39 of file sha256.hpp.

Constructor & Destructor Documentation

◆ SHA256() [1/3]

SHA256 ( )

construct empty object.

Definition at line 142 of file sha256.cpp.

◆ SHA256() [2/3]

SHA256 ( const void *  data,
uint32_t  size 
)

construct context and process data range

Definition at line 155 of file sha256.cpp.

◆ SHA256() [3/3]

SHA256 ( const std::string &  str)
explicit

construct context and process string

Definition at line 160 of file sha256.cpp.

Member Function Documentation

◆ digest()

std::string digest ( )

finalize computation and return 32 byte (256 bit) digest

Definition at line 231 of file sha256.cpp.

◆ digest_hex()

std::string digest_hex ( )

finalize computation and return 32 byte (256 bit) digest hex encoded

Definition at line 237 of file sha256.cpp.

◆ digest_hex_uc()

std::string digest_hex_uc ( )

finalize computation and return 32 byte (256 bit) digest upper-case hex

Definition at line 243 of file sha256.cpp.

◆ finalize()

void finalize ( void *  digest)

finalize computation and output 32 byte (256 bit) digest

Definition at line 200 of file sha256.cpp.

◆ process() [1/2]

void process ( const std::string &  str)

process more data

Definition at line 196 of file sha256.cpp.

◆ process() [2/2]

void process ( const void *  data,
uint32_t  size 
)

process more data

Definition at line 165 of file sha256.cpp.

Member Data Documentation

◆ buf_

uint8_t buf_[64]
private

Definition at line 71 of file sha256.hpp.

◆ curlen_

uint32_t curlen_
private

Definition at line 70 of file sha256.hpp.

◆ kDigestLength

constexpr size_t kDigestLength
staticconstexpr

digest length in bytes

Definition at line 55 of file sha256.hpp.

◆ length_

uint64_t length_
private

Definition at line 68 of file sha256.hpp.

◆ state_

uint32_t state_[8]
private

Definition at line 69 of file sha256.hpp.


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