util/HexFormat: use std::span instead of ConstBuffer
This commit is contained in:

committed by
Max Kellermann

parent
8333927737
commit
27e78c71e0
@@ -50,21 +50,22 @@ GlobalInitMD5() noexcept
|
||||
#endif
|
||||
}
|
||||
|
||||
std::array<uint8_t, 16>
|
||||
MD5(ConstBuffer<void> input) noexcept
|
||||
std::array<std::byte, 16>
|
||||
MD5(std::span<const std::byte> input) noexcept
|
||||
{
|
||||
#ifdef HAVE_LIBAVUTIL
|
||||
std::array<uint8_t, 16> result;
|
||||
av_md5_sum(&result.front(), (const uint8_t *)input.data, input.size);
|
||||
std::array<std::byte, 16> result;
|
||||
av_md5_sum((uint8_t *)result.data(),
|
||||
(const uint8_t *)input.data(), input.size());
|
||||
return result;
|
||||
#else
|
||||
return Gcrypt::MD5(input);
|
||||
#endif
|
||||
}
|
||||
|
||||
StringBuffer<33>
|
||||
MD5Hex(ConstBuffer<void> input) noexcept
|
||||
std::array<char, 32>
|
||||
MD5Hex(std::span<const std::byte> input) noexcept
|
||||
{
|
||||
const auto raw = MD5(input);
|
||||
return HexFormatBuffer<raw.size()>(&raw.front());
|
||||
return HexFormat<raw.size()>(raw);
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2019 Max Kellermann <max.kellermann@gmail.com>
|
||||
* Copyright 2018-2022 Max Kellermann <max.kellermann@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -27,25 +27,18 @@
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MD5_HXX
|
||||
#define MD5_HXX
|
||||
|
||||
#include "util/StringBuffer.hxx"
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
|
||||
template<typename T> struct ConstBuffer;
|
||||
#include <span>
|
||||
|
||||
void
|
||||
GlobalInitMD5() noexcept;
|
||||
|
||||
[[gnu::pure]]
|
||||
std::array<uint8_t, 16>
|
||||
MD5(ConstBuffer<void> input) noexcept;
|
||||
std::array<std::byte, 16>
|
||||
MD5(std::span<const std::byte> input) noexcept;
|
||||
|
||||
[[gnu::pure]]
|
||||
StringBuffer<33>
|
||||
MD5Hex(ConstBuffer<void> input) noexcept;
|
||||
|
||||
#endif
|
||||
std::array<char, 32>
|
||||
MD5Hex(std::span<const std::byte> input) noexcept;
|
||||
|
Reference in New Issue
Block a user