digestpp  0.01
Experimental C++11 header-only message digest library.
sha2.hpp
1 /*
2 This code is written by kerukuro and released into public domain.
3 */
4 
5 #ifndef DIGESTPP_ALGORITHM_SHA2_HPP
6 #define DIGESTPP_ALGORITHM_SHA2_HPP
7 
8 #include "../hasher.hpp"
9 #include "detail/sha2_provider.hpp"
10 
11 namespace digestpp
12 {
13 
14 /**
15  * @brief SHA-512 hash function
16  *
17  * @hash
18  *
19  * @outputsize 8 - 512 bits
20  *
21  * @defaultsize 512 bits
22  *
23  * @throw std::runtime_error if the requested digest size is not divisible by 8 (full bytes),
24  * or is not within the supported range
25  *
26  * @par Example:\n
27  * @code // Output a SHA-512/256 digest of a string
28  * digestpp::sha512 hasher(256);
29  * hasher.absorb("The quick brown fox jumps over the lazy dog");
30  * std::cout << hasher.hexdigest() << '\n';
31  * @endcode
32  *
33  * @par Example output:\n
34  * @code dd9d67b371519c339ed8dbd25af90e976a1eeefd4ad3d889005e532fc5bef04d
35  * @endcode
36  *
37  * @sa hasher
38  */
40 
41 /**
42  * @brief SHA-384 hash function
43  *
44  * @hash
45  *
46  * @outputsize 384 bits
47  *
48  * @defaultsize 384 bits
49  *
50  * @par Example:\n
51  * @code // Output a SHA-384 digest of a string
52  * digestpp::sha384 hasher;
53  * hasher.absorb("The quick brown fox jumps over the lazy dog");
54  * std::cout << hasher.hexdigest() << '\n';
55  * @endcode
56  *
57  * @par Example output:\n
58  * @code ca737f1014a48f4c0b6dd43cb177b0afd9e5169367544c494011e3317dbf9a509cb1e5dc1e85a941bbee3d7f2afbc9b1
59  * @endcode
60  *
61  * @sa hasher
62  */
64 
65 /**
66  * @brief SHA-256 hash function
67  *
68  * Note that this function is slower than SHA-512/256 on 64-bit systems.
69  *
70  * @hash
71  *
72  * @outputsize 256 bits
73  *
74  * @defaultsize 256 bits
75  *
76  * @par Example:\n
77  * @code // Output a SHA-256 digest of a string
78  * digestpp::sha256 hasher;
79  * hasher.absorb("The quick brown fox jumps over the lazy dog");
80  * std::cout << hasher.hexdigest() << '\n';
81  * @endcode
82  *
83  * @par Example output:\n
84  * @code d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592
85  * @endcode
86  *
87  * @sa hasher
88  */
90 
91 /**
92  * @brief SHA-224 hash function
93  *
94  * @hash
95  *
96  * @outputsize 224 bits
97  *
98  * @defaultsize 224 bits
99  *
100  * @par Example:\n
101  * @code // Output a SHA-224 digest of a string
102  * digestpp::sha224 hasher;
103  * hasher.absorb("The quick brown fox jumps over the lazy dog");
104  * std::cout << hasher.hexdigest() << '\n';
105  * @endcode
106  *
107  * @par Example output:\n
108  * @code 730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525
109  * @endcode
110  *
111  * @sa hasher
112  */
114 
115 
116 } // namespace digestpp
117 
118 #endif
hasher< detail::shake_provider< 256, 24 > > shake256
SHAKE256 function.
Definition: shake.hpp:53
hasher< detail::sha2_provider< uint64_t > > sha512
SHA-512 hash function.
Definition: sha2.hpp:39