forked from MusicPlayerDaemon/MPD
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
util/HexFormat: use std::span instead of ConstBuffer
- Loading branch information
1 parent
8333927
commit 27e78c7
Showing
7 changed files
with
51 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright 2018-2019 Max Kellermann <[email protected]> | ||
* Copyright 2018-2022 Max Kellermann <[email protected]> | ||
* | ||
* 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (C) 2018 Max Kellermann <[email protected]> | ||
* Copyright 2018-2022 Max Kellermann <[email protected]> | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
|
@@ -27,28 +27,24 @@ | |
* OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef GCRYPT_HASH_HXX | ||
#define GCRYPT_HASH_HXX | ||
|
||
#include "util/ConstBuffer.hxx" | ||
#pragma once | ||
|
||
#include <gcrypt.h> | ||
|
||
#include <array> | ||
#include <span> | ||
|
||
namespace Gcrypt { | ||
|
||
template<int algo, size_t size> | ||
[[gnu::pure]] | ||
auto | ||
Hash(ConstBuffer<void> input) noexcept | ||
Hash(std::span<const std::byte> input) noexcept | ||
{ | ||
std::array<uint8_t, size> result; | ||
std::array<std::byte, size> result; | ||
gcry_md_hash_buffer(algo, &result.front(), | ||
input.data, input.size); | ||
input.data(), input.size()); | ||
return result; | ||
} | ||
|
||
} /* namespace Gcrypt */ | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright 2018-2019 Max Kellermann <[email protected]> | ||
* Copyright 2018-2022 Max Kellermann <[email protected]> | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
|
@@ -32,8 +32,8 @@ | |
|
||
namespace Gcrypt { | ||
|
||
std::array<uint8_t, 16> | ||
MD5(ConstBuffer<void> input) noexcept | ||
std::array<std::byte, 16> | ||
MD5(std::span<const std::byte> input) noexcept | ||
{ | ||
return Gcrypt::Hash<GCRY_MD_MD5, 16>(input); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright 2018-2019 Max Kellermann <[email protected]> | ||
* Copyright 2018-2022 Max Kellermann <[email protected]> | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
|
@@ -27,22 +27,15 @@ | |
* OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef GCRYPT_MD5_HXX | ||
#define GCRYPT_MD5_HXX | ||
|
||
#include "util/StringBuffer.hxx" | ||
#pragma once | ||
|
||
#include <array> | ||
#include <cstdint> | ||
|
||
template<typename T> struct ConstBuffer; | ||
#include <span> | ||
|
||
namespace Gcrypt { | ||
|
||
[[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; | ||
|
||
} // namespace Gcrypt | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters