52 G_EXCEPTION( Error ,
tx(
"internal md5 error") )
53 G_EXCEPTION_CLASS( InvalidState ,
tx(
"invalid md5 hash state") )
54 using big_t = std::size_t ;
55 using small_t = std::size_t ;
57 { big_t a ; big_t b ; big_t c ; big_t d ; } ;
60 static_assert(
sizeof(big_t) >= 4 ,
"" ) ;
61 static_assert(
sizeof(small_t) >=
sizeof(std::size_t) &&
sizeof(small_t) <=
sizeof(big_t) ,
"" ) ;
66 explicit Md5(
const std::string &
state ) ;
70 std::string
state()
const ;
78 void add(
const std::string & data ) ;
81 void add(
const char * data , std::size_t size ) ;
99 static std::string
digest(
const std::string & input ) ;
103 static std::string
digest( std::string_view input ) ;
107 static std::string
digest(
const std::string & input_1 ,
const std::string & input_2 ) ;
111 static std::string
digest( std::string_view input_1 , std::string_view input_2 ) ;
115 static std::string
digest2(
const std::string & input_1 ,
const std::string & input_2 ) ;
119 static std::string
predigest(
const std::string & padded_key ) ;
125 static std::string
postdigest(
const std::string & state_pair ,
const std::string & message ) ;
137 Md5(
const Md5 & ) = delete ;
139 Md5 & operator=(
const Md5 & ) = delete ;
140 Md5 & operator=(
Md5 && ) = delete ;
146 std::size_t m_n{0U} ;
MD5 message digest class.
static std::string postdigest(const std::string &state_pair, const std::string &message)
A convenience function that returns the value() from an outer digest that is initialised with the sec...
static std::size_t blocksize()
Returns the block size in bytes (64).
static std::string predigest(const std::string &padded_key)
A convenience function that add()s the given string of length blocksize() (typically a padded key) an...
static std::string digest2(const std::string &input_1, const std::string &input_2)
A non-overloaded name for the digest() overload taking two parameters.
static std::string digest(const std::string &input)
A convenience function that returns a digest from one input.
void add(const std::string &data)
Adds more data.
std::string value()
Returns the hash value as a 16-character string.
static std::size_t statesize()
Returns the size of the state() string (20).
static std::size_t valuesize()
Returns the value() size in bytes (16).
Md5()
Default constructor.
std::string state() const
Returns the current intermediate state as a 20 character string, although this requires the size of t...
constexpr const char * tx(const char *p) noexcept
A briefer alternative to G::gettext_noop().
Holds the four parts of the md5 state.
Holds the md5 state plus unprocessed residual data.