lib/gcrypt/MD5: return a StringBuffer

This commit is contained in:
Max Kellermann 2018-07-26 17:45:45 +02:00
parent 7f81375861
commit 409d3c7136
3 changed files with 6 additions and 5 deletions

View File

@ -213,7 +213,7 @@ QobuzClient::MakeSignedUrl(const char *object, const char *method,
concatenated_query += app_secret;
const auto md5_hex = MD5Hex({concatenated_query.data(), concatenated_query.size()});
q(uri, "request_sig", &md5_hex.front());
q(uri, "request_sig", md5_hex);
return uri;
}

View File

@ -38,13 +38,13 @@ MD5(ConstBuffer<void> input) noexcept
return Gcrypt::Hash<GCRY_MD_MD5, 16>(input);
}
std::array<char, 33>
StringBuffer<33>
MD5Hex(ConstBuffer<void> input) noexcept
{
const auto raw = MD5(input);
std::array<char, 33> result;
StringBuffer<33> result;
char *p = &result.front();
char *p = result.data();
for (const auto i : raw) {
sprintf(p, "%02x", i);
p += 2;

View File

@ -30,6 +30,7 @@
#ifndef GCRYPT_MD5_HXX
#define GCRYPT_MD5_HXX
#include "util/StringBuffer.hxx"
#include "Compiler.h"
#include <array>
@ -41,7 +42,7 @@ std::array<uint8_t, 16>
MD5(ConstBuffer<void> input) noexcept;
gcc_pure
std::array<char, 33>
StringBuffer<33>
MD5Hex(ConstBuffer<void> input) noexcept;
#endif