|
CryptoSys API
6.22.1
|
Message digest hash functions. More...
Public Types | |
| enum class | Alg |
| Hash algorithm. More... | |
Public Member Functions | |
| int | AddData (bvec_t data) |
| Adds a chunk of data in a byte array to be digested by the Hash object. More... | |
| int | AddData (std::string s) |
| Adds a chunk of data in a string to be digested by the Hash object. More... | |
| bvec_t | Final () |
| Computes final message digest for the Hash object. More... | |
| bool | Init (Alg alg) |
| Initialises the Hash object ready for repeated incremental operations. More... | |
Static Public Member Functions | |
| static std::string | AlgName (Alg alg) |
| Get the algorithm name as a string. More... | |
| static bvec_t | BytesFromBytes (const bvec_t &data, Alg alg=Alg::Sha1) |
| Compute hash value in byte format of byte input. More... | |
| static bvec_t | BytesFromFile (const std::string &fileName, Alg alg=Alg::Sha1) |
| Compute hash value in byte format of a binary file. More... | |
| static std::string | HexFromBits (const bvec_t &data, int dataBitLen, Alg alg=Alg::Sha1) |
| Compute hash value in hex format from bit-oriented input. More... | |
| static std::string | HexFromBytes (const bvec_t &data, Alg alg=Alg::Sha1) |
| Computes hash value in hex format of byte input. More... | |
| static std::string | HexFromFile (const std::string &fileName, Alg alg=Alg::Sha1) |
| Compute hash value in hex format of a binary file. More... | |
| static std::string | HexFromHex (const std::string &dataHex, Alg alg=Alg::Sha1) |
| Compute hash value in hex format of hex-encoded input. More... | |
| static std::string | HexFromString (const std::string &s, Alg alg=Alg::Sha1) |
| Compute hash value in hex format of string input. More... | |
| static std::string | HexFromTextFile (const std::string &fileName, Alg alg=Alg::Sha1) |
| Compute hash value in hex format of a text file, treating CR-LF pairs as a single LF. More... | |
| static int | LengthInBytes (Alg alg) |
| Get the number of bytes in the message digest for the given hash algorithm. More... | |
Message digest hash functions.
|
strong |
Hash algorithm.
| int crsysapi::Hash::AddData | ( | bvec_t | data | ) |
Adds a chunk of data in a byte array to be digested by the Hash object.
| data | Data to add |
| std::runtime_error | if object is not valid. |
| int crsysapi::Hash::AddData | ( | std::string | s | ) |
Adds a chunk of data in a string to be digested by the Hash object.
| s | Data to add |
| std::runtime_error | if object is not valid. |
|
static |
Get the algorithm name as a string.
| alg | Hash algorithm |
Compute hash value in byte format of byte input.
| data | Message data in byte format |
| alg | Hash algorithm to be used |
|
static |
Compute hash value in byte format of a binary file.
| fileName | Name of file containing message data |
| alg | Hash algorithm to be used (ASCON is not supported in file mode) |
| std::runtime_error | if file does not exist or cannot be opened. |
| bvec_t crsysapi::Hash::Final | ( | ) |
Computes final message digest for the Hash object.
| std::runtime_error | if object is not valid. |
|
static |
Compute hash value in hex format from bit-oriented input.
| data | Bit-oriented message data in byte array |
| dataBitLen | Number of bits in data to digest |
| alg | Hash algorithm to be used |
dataBitLen and extraneous bits on the right will be ignored. Only the SHA family of hash functions (SHA-1, SHA-2, SHA-3) is supported in bit-oriented mode. | std::runtime_error | if algorithm is not supported or if data is too short for the required number of bits. |
Computes hash value in hex format of byte input.
| data | Message data in byte format |
| alg | Hash algorithm to be used |
|
static |
Compute hash value in hex format of a binary file.
| fileName | Name of file containing message data |
| alg | Hash algorithm to be used |
| std::runtime_error | if file does not exist or cannot be opened. |
|
static |
Compute hash value in hex format of hex-encoded input.
| dataHex | Message data in hex-encoded format |
| alg | Hash algorithm to be used (ASCON is not supported in file mode) |
|
static |
Compute hash value in hex format of string input.
| s | Message data string |
| alg | Hash algorithm to be used |
|
static |
Compute hash value in hex format of a text file, treating CR-LF pairs as a single LF.
| fileName | Name of file containing message data |
| alg | Hash algorithm to be used |
| std::runtime_error | if file does not exist or cannot be opened. |
| bool crsysapi::Hash::Init | ( | Alg | alg | ) |
Initialises the Hash object ready for repeated incremental operations.
| alg | Hash algorithm to be used |
| std::runtime_error | if algorithm is not supported. |