scclib
Stable Cloud Computing C++ Library
Static Public Member Functions | List of all members
scc::encode::Hex Class Reference

Static Public Member Functions

static void bin_to_hex (const std::vector< char > &, std::string &, bool=true)
 Encode to hex from binary. More...
 
static void bin_to_hex (const void *, size_t, std::string &, bool=true)
 Encode to hex from binary. More...
 
static std::string bin_to_hex (const std::vector< char > &, bool=true)
 Encode to hex from binary. More...
 
static std::string bin_to_hex (const void *, size_t, bool=true)
 Encode to hex from binary. More...
 
static void hex_to_bin (const std::string &, std::vector< char > &)
 Decode from hex to binary. More...
 
static std::string bin_to_hexstr (const std::vector< char > &, const std::string &="", int limit=-1, const std::string &=" +more", bool=true)
 Binary to human readable string. More...
 
static std::string bin_to_hexstr (const void *, size_t, const std::string &="", int limit=-1, const std::string &=" +more", bool=true)
 Binary to human readable string. More...
 

Detailed Description

Examples
crypto/unittest/bignum.cc, encode/unittest/hex.cc, and scclib/crypto/unittest/der.cc.

Definition at line 53 of file hex.h.

Member Function Documentation

◆ bin_to_hex() [1/4]

std::string Hex::bin_to_hex ( const std::vector< char > &  bin,
bool  lower_case = true 
)
static

Encode to hex from binary.

Encodes using two characters per byte.

Parameters
binBinary input.
lower_caseOutput lower case flag.
Returns
Hex string output.

Definition at line 119 of file hex.cc.

◆ bin_to_hex() [2/4]

void Hex::bin_to_hex ( const std::vector< char > &  bin,
std::string &  hex,
bool  lower_case = true 
)
static

Encode to hex from binary.

Encodes using two characters per byte.

Parameters
binBinary input.
hexString output.
lower_caseOutput lower case flag.

Definition at line 107 of file hex.cc.

◆ bin_to_hex() [3/4]

std::string Hex::bin_to_hex ( const void *  loc,
size_t  len,
bool  lower_case = true 
)
static

Encode to hex from binary.

Encodes using two characters per byte.

Parameters
locBinary input buffer.
lenBinary input buffer size.
lower_caseOutput lower case flag.
Returns
Hex string output.

Definition at line 112 of file hex.cc.

◆ bin_to_hex() [4/4]

void Hex::bin_to_hex ( const void *  xloc,
size_t  len,
std::string &  hex,
bool  lower_case = true 
)
static

Encode to hex from binary.

Encodes using two characters per byte.

Parameters
locBinary input buffer.
lenBinary input buffer size.
hexString output.
lower_caseOutput lower case flag.

Definition at line 37 of file hex.cc.

◆ bin_to_hexstr() [1/2]

std::string Hex::bin_to_hexstr ( const std::vector< char > &  bin,
const std::string &  delimit = "",
int  limit = -1,
const std::string &  limit_msg = " +more",
bool  lower_case = true 
)
static

Binary to human readable string.

Parameters
binBinary input.
lower_caseOutput lower case flag.
delimitDelimiter for output (placed between bytes)
limitLimit in bytes (< 0 means no limit)
limit_msgMessage to add if limit exceeded
lower_caseUse lower case

Output message of form HH<delimit>HH<delimit>[limit_msg]

Definition at line 102 of file hex.cc.

◆ bin_to_hexstr() [2/2]

std::string Hex::bin_to_hexstr ( const void *  loc,
size_t  len,
const std::string &  delimit = "",
int  limit = -1,
const std::string &  limit_msg = " +more",
bool  lower_case = true 
)
static

Binary to human readable string.

Parameters
locBinary input buffer.
lenBinary input buffer size.
lower_caseOutput lower case flag.
delimitDelimiter for output (placed between bytes)
limitLimit in bytes (< 0 means no limit)
limit_msgMessage to add if limit exceeded
lower_caseUse lower case

Output message of form HH<delimit>HH<delimit>[limit_msg]

Definition at line 74 of file hex.cc.

◆ hex_to_bin()

void Hex::hex_to_bin ( const std::string &  hex,
std::vector< char > &  bin 
)
static

Decode from hex to binary.

Encodes using two characters per byte.

Parameters
hexstring input.
binBinary output.

Definition at line 126 of file hex.cc.


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