lib/gcrypt/MD5: add wrapper in lib/crypto/

Prepare for using other crypto libraries, e.g. FFmpeg's libavutil.
This commit is contained in:
Max Kellermann
2019-08-13 17:20:07 +02:00
parent 2c2efaa91f
commit d515a8e99a
9 changed files with 136 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 Max Kellermann <max.kellermann@gmail.com>
* Copyright 2018-2019 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
@@ -29,7 +29,8 @@
#include "MD5.hxx"
#include "Hash.hxx"
#include "util/HexFormat.hxx"
namespace Gcrypt {
std::array<uint8_t, 16>
MD5(ConstBuffer<void> input) noexcept
@@ -37,9 +38,4 @@ MD5(ConstBuffer<void> input) noexcept
return Gcrypt::Hash<GCRY_MD_MD5, 16>(input);
}
StringBuffer<33>
MD5Hex(ConstBuffer<void> input) noexcept
{
const auto raw = MD5(input);
return HexFormatBuffer<raw.size()>(&raw.front());
}
} // namespace Gcrypt

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 Max Kellermann <max.kellermann@gmail.com>
* Copyright 2018-2019 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
@@ -37,12 +37,12 @@
template<typename T> struct ConstBuffer;
namespace Gcrypt {
gcc_pure
std::array<uint8_t, 16>
MD5(ConstBuffer<void> input) noexcept;
gcc_pure
StringBuffer<33>
MD5Hex(ConstBuffer<void> input) noexcept;
} // namespace Gcrypt
#endif