Codechange: make the MD5 hash/digest/checksum variables a std::array
This commit is contained in:
2
src/3rdparty/md5/md5.cpp
vendored
2
src/3rdparty/md5/md5.cpp
vendored
@@ -297,7 +297,7 @@ void Md5::Append(const void *data, const size_t nbytes)
|
||||
if (left) memcpy(this->buf, p, left);
|
||||
}
|
||||
|
||||
void Md5::Finish(uint8 digest[16])
|
||||
void Md5::Finish(MD5Hash &digest)
|
||||
{
|
||||
static const uint8 pad[64] = {
|
||||
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
21
src/3rdparty/md5/md5.h
vendored
21
src/3rdparty/md5/md5.h
vendored
@@ -53,6 +53,25 @@
|
||||
#ifndef MD5_INCLUDED
|
||||
#define MD5_INCLUDED
|
||||
|
||||
/** The number of bytes in a MD5 hash. */
|
||||
static const size_t MD5_HASH_BYTES = 16;
|
||||
|
||||
/** Container for storing a MD5 hash/checksum/digest. */
|
||||
using MD5Hash = std::array<byte, MD5_HASH_BYTES>;
|
||||
|
||||
/**
|
||||
* Exclusively-or one hash into another hash.
|
||||
* @param lhs The hash to exclusively-or into.
|
||||
* @param rhs The hash to exclusively-or with.
|
||||
* @return Reference to \c lhs hash.
|
||||
*/
|
||||
inline MD5Hash &operator^=(MD5Hash &lhs, const MD5Hash &rhs)
|
||||
{
|
||||
for (size_t i = 0; i < lhs.size(); i++) lhs[i] ^= rhs[i];
|
||||
return lhs;
|
||||
}
|
||||
|
||||
|
||||
struct Md5 {
|
||||
private:
|
||||
uint32 count[2]; ///< message length in bits, lsw first
|
||||
@@ -64,7 +83,7 @@ private:
|
||||
public:
|
||||
Md5();
|
||||
void Append(const void *data, const size_t nbytes);
|
||||
void Finish(uint8 digest[16]);
|
||||
void Finish(MD5Hash &digest);
|
||||
};
|
||||
|
||||
#endif /* MD5_INCLUDED */
|
||||
|
||||
Reference in New Issue
Block a user