You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
451 B
C++
25 lines
451 B
C++
// SPDX-License-Identifier: BSD-2-Clause
|
|
// author: Max Kellermann <max.kellermann@gmail.com>
|
|
|
|
#pragma once
|
|
|
|
#include <gcrypt.h>
|
|
|
|
#include <array>
|
|
#include <span>
|
|
|
|
namespace Gcrypt {
|
|
|
|
template<int algo, std::size_t size>
|
|
[[gnu::pure]]
|
|
auto
|
|
Hash(std::span<const std::byte> input) noexcept
|
|
{
|
|
std::array<std::byte, size> result;
|
|
gcry_md_hash_buffer(algo, &result.front(),
|
|
input.data(), input.size());
|
|
return result;
|
|
}
|
|
|
|
} /* namespace Gcrypt */
|