digestpp 1.0
C++11 header-only message digest library
Loading...
Searching...
No Matches
SHA2

SHA2 Algorithm More...

Typedefs

typedef hasher< detail::sha2_provider< uint64_t > > digestpp::sha512
 SHA-512 hash function.
 
typedef hasher< detail::sha2_provider< uint64_t, 384 > > digestpp::sha384
 SHA-384 hash function.
 
typedef hasher< detail::sha2_provider< uint32_t, 256 > > digestpp::sha256
 SHA-256 hash function.
 
typedef hasher< detail::sha2_provider< uint32_t, 224 > > digestpp::sha224
 SHA-224 hash function.
 
template<size_t N>
using digestpp::static_size::sha512 = hasher<detail::sha2_provider<uint64_t, N>>
 SHA-512 hash function (static-size version)
 

Detailed Description

SHA2 Algorithm

Typedef Documentation

◆ sha224

typedef hasher<detail::sha2_provider<uint32_t, 224> > digestpp::sha224

SHA-224 hash function.

Member of the SHA-2 family, widely used cryptographic hash function. Designed by the NSA and published by NIST in 2001 as part of FIPS 180-2.

SHA-224 is SHA-256 with different initial values and truncated output. It uses the same algorithm and has similar performance characteristics. Designed to provide 112-bit security level.

SHA-224 uses 32-bit operations and is optimized for 32-bit platforms. On 64-bit systems, SHA-512/224 may offer better performance.

Specified in FIPS 180-4.

Type:
Cryptographic hash function.
Output size:
224 bits
Default size:
224 bits
Example:
// Output a SHA-224 digest of a string
hasher.absorb("The quick brown fox jumps over the lazy dog");
std::cout << hasher.hexdigest() << '\n';
Main class template implementing the public API for hashing.
Definition hasher.hpp:38
std::string hexdigest() const
Return hex digest of absorbed data.
Definition hasher.hpp:372
hasher & absorb(const T *data, size_t len)
Absorbs bytes from a C-style pointer to character buffer.
Definition hasher.hpp:86
Example output:
730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525
See also
hasher, sha512, digestpp::static_size::sha512

◆ sha256

typedef hasher<detail::sha2_provider<uint32_t, 256> > digestpp::sha256

SHA-256 hash function.

Member of the SHA-2 family, widely used cryptographic hash function. Designed by the NSA and published by NIST in 2001 as part of FIPS 180-2.

SHA-256 uses 32-bit operations and is optimized for 32-bit platforms. On 64-bit systems, SHA-512/256 may offer better performance.

Specified in FIPS 180-4.

Type:
Cryptographic hash function.
Output size:
256 bits
Default size:
256 bits
Example:
// Output a SHA-256 digest of a string
hasher.absorb("The quick brown fox jumps over the lazy dog");
std::cout << hasher.hexdigest() << '\n';
Example output:
d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592
See also
hasher, sha512, digestpp::static_size::sha512

◆ sha384

typedef hasher<detail::sha2_provider<uint64_t, 384> > digestpp::sha384

SHA-384 hash function.

Member of the SHA-2 family, widely used cryptographic hash function. Designed by the NSA and published by NIST in 2001 as part of FIPS 180-2.

Uses 64-bit operations and is optimized for 64-bit platforms.

SHA-384 is SHA-512 with different initial values and truncated to 384 bits. It provides 192-bit security level.

Specified in FIPS 180-4. Good balance between security and performance for 64-bit systems.

Type:
Cryptographic hash function.
Output size:
384 bits
Default size:
384 bits
Example:
// Output a SHA-384 digest of a string
hasher.absorb("The quick brown fox jumps over the lazy dog");
std::cout << hasher.hexdigest() << '\n';
Example output:
ca737f1014a48f4c0b6dd43cb177b0afd9e5169367544c494011e3317dbf9a509cb1e5dc1e85a941bbee3d7f2afbc9b1
See also
hasher

◆ sha512 [1/2]

SHA-512 hash function.

Member of the SHA-2 family, widely used cryptographic hash function. Designed by the NSA and published by NIST in 2001 as part of FIPS 180-2.

64-bit variant of SHA-2 family, providing high security and performance on 64-bit platforms.

SHA-512 can produce outputs from 8 to 512 bits. Truncated variants (SHA-512/t) provide outputs different from other SHA-2 functions of the same length. For example: SHA-512/256 ≠ SHA-256 (different algorithm, different output).

Specified in FIPS 180-4.

SHA-512/256 is recommended over SHA-256 on 64-bit systems for better performance. Full SHA-512 (512-bit output) provides the highest security in SHA-2 family.

Type:
Cryptographic hash function.
Output size:
8 - 512 bits
Default size:
512 bits
Exceptions
std::runtime_errorif the requested digest size is not divisible by 8 (full bytes), or is not within the supported range
Example:
// Output a SHA-512/256 digest of a string
hasher.absorb("The quick brown fox jumps over the lazy dog");
std::cout << hasher.hexdigest() << '\n';
Example output:
dd9d67b371519c339ed8dbd25af90e976a1eeefd4ad3d889005e532fc5bef04d
See also
hasher, digestpp::static_size::sha512

◆ sha512 [2/2]

template<size_t N>
using digestpp::static_size::sha512 = hasher<detail::sha2_provider<uint64_t, N>>

SHA-512 hash function (static-size version)

Variant of SHA-512 with output size specified as template parameter.

Type:
Cryptographic hash function.
Output size:
8 - 512 bits
Example:
// Output a SHA-512/256 digest of a string
hasher.absorb("The quick brown fox jumps over the lazy dog");
std::cout << hasher.hexdigest() << '\n';
Definition blake.hpp:63
Example output:
dd9d67b371519c339ed8dbd25af90e976a1eeefd4ad3d889005e532fc5bef04d
See also
hasher, digestpp::sha512