digestpp  0.01
Experimental C++11 header-only message digest library.
shake.hpp
1 /*
2 This code is written by kerukuro and released into public domain.
3 */
4 
5 #ifndef DIGESTPP_ALGORITHM_SHAKE_HPP
6 #define DIGESTPP_ALGORITHM_SHAKE_HPP
7 
8 #include "../hasher.hpp"
9 #include "detail/shake_provider.hpp"
10 #include "mixin/cshake_mixin.hpp"
11 
12 namespace digestpp
13 {
14 
15 /**
16  * @brief SHAKE128 function
17  *
18  * @xof
19  *
20  * @par Example:\n
21  * @code // Absorb a string and squeeze 32 bytes of output
22  * digestpp::shake128 hasher;
23  * hasher.absorb("The quick brown fox jumps over the lazy dog");
24  * std::cout << hasher.hexsqueeze(32) << '\n';
25  * @endcode
26  *
27  * @par Example output:\n
28  * @code f4202e3c5852f9182a0430fd8144f0a74b95e7417ecae17db0f8cfeed0e3e66e
29  * @endcode
30  *
31  * @sa hasher, cshake128
32  */
33 typedef hasher<detail::shake_provider<128, 24>> shake128;
34 
35 /**
36  * @brief SHAKE256 function
37  *
38  * @xof
39  *
40  * @par Example:\n
41  * @code // Absorb a string and squeeze 32 bytes of output
42  * digestpp::shake256 hasher;
43  * hasher.absorb("The quick brown fox jumps over the lazy dog");
44  * std::cout << hasher.hexsqueeze(32) << '\n';
45  * @endcode
46  *
47  * @par Example output:\n
48  * @code 2f671343d9b2e1604dc9dcf0753e5fe15c7c64a0d283cbbf722d411a0e36f6ca
49  * @endcode
50  *
51  * @sa hasher, cshake256
52  */
53 typedef hasher<detail::shake_provider<256, 24>> shake256;
54 
55 /**
56  * @brief Customizable cSHAKE128 function
57  *
58  * Extendable output function similar to SHAKE128 but with possibility to use a customization string.
59  * When used without a customization string, the output is identical to \ref shake128.
60  *
61  * @xof
62  *
63  * @mixinparams function name, customization
64  *
65  * @mixin{mixin::cshake_mixin}
66  *
67  * @par Example:\n
68  * @code // Absorb a string and squeeze 32 bytes of output
69  * digestpp::cshake128 hasher;
70  * hasher.set_customization("My Custom SHAKE");
71  * hasher.absorb("The quick brown fox jumps over the lazy dog");
72  * std::cout << hasher.hexsqueeze(32) << '\n';
73  * @endcode
74  *
75  * @par Example output:\n
76  * @code 5b831bfe752f7f05d81f18f0e83a92eb48b9e3d460c10022ecb4852aa8b1f9d4
77  * @endcode
78  *
79  * @sa hasher, mixin::cshake_mixin
80  */
82 
83 /**
84  * @brief Customizable cSHAKE256 function
85  *
86  * Extendable output function similar to SHAKE256 but with possibility to use a customization string.
87  * When used without a customization string, the output is identical to \ref shake256.
88  *
89  * @xof
90  *
91  * @mixinparams function name, customization
92  *
93  * @mixin{mixin::cshake_mixin}
94  *
95  * @par Example:\n
96  * @code // Absorb a string and squeeze 32 bytes of output
97  * digestpp::cshake256 hasher;
98  * hasher.set_customization("My Custom SHAKE");
99  * hasher.absorb("The quick brown fox jumps over the lazy dog");
100  * std::cout << hasher.hexsqueeze(32) << '\n';
101  * @endcode
102  *
103  * @par Example output:\n
104  * @code bcebde2c2e18f6efd99ee9e0def1383e86595d72e49b4754f7f727a962c3cd3d
105  * @endcode
106  *
107  * @sa hasher, mixin::cshake_mixin
108  */
110 
111 } // namespace digestpp
112 
113 #endif // DIGESTPP_ALGORITHM_SHAKE_HPP
hasher< detail::shake_provider< 256, 24 > > shake256
SHAKE256 function.
Definition: shake.hpp:53
hasher< detail::shake_provider< 256, 24 >, mixin::cshake_mixin > cshake256
Customizable cSHAKE256 function.
Definition: shake.hpp:109
hasher< detail::shake_provider< 128, 24 >, mixin::cshake_mixin > cshake128
Customizable cSHAKE128 function.
Definition: shake.hpp:81