diff options
author | Lee Clagett <code@leeclagett.com> | 2017-02-27 13:33:16 -0500 |
---|---|---|
committer | Lee Clagett <code@leeclagett.com> | 2017-04-11 16:35:00 -0400 |
commit | 4a8f96f95da51e6b570a00ddcfefe100844d8f8b (patch) | |
tree | ac8e18d7c08d336eac28481727f2accc00b1b544 /contrib/epee/src/http_auth.cpp | |
parent | Merge pull request #1956 (diff) | |
download | monero-4a8f96f95da51e6b570a00ddcfefe100844d8f8b.tar.xz |
Improvements for epee binary to hex functions:
- Performance improvements
- Added `span` for zero-copy pointer+length arguments
- Added `std::ostream` overload for direct writing to output buffers
- Removal of unused `string_tools::buff_to_hex`
Diffstat (limited to '')
-rw-r--r-- | contrib/epee/src/http_auth.cpp | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/contrib/epee/src/http_auth.cpp b/contrib/epee/src/http_auth.cpp index 5a1c2142a..30e562700 100644 --- a/contrib/epee/src/http_auth.cpp +++ b/contrib/epee/src/http_auth.cpp @@ -67,6 +67,7 @@ #include <type_traits> #include "crypto/crypto.h" +#include "hex.h" #include "md5_l.h" #include "string_coding.h" @@ -104,25 +105,6 @@ namespace //// Digest Algorithms - template<std::size_t N> - std::array<char, N * 2> to_hex(const std::array<std::uint8_t, N>& digest) noexcept - { - static constexpr const char alphabet[] = u8"0123456789abcdef"; - static_assert(sizeof(alphabet) == 17, "bad alphabet size"); - - // TODO upgrade (improve performance) of to hex in epee string tools - std::array<char, N * 2> out{{}}; - auto current = out.begin(); - for (const std::uint8_t byte : digest) - { - *current = alphabet[byte >> 4]; - ++current; - *current = alphabet[byte & 0x0F]; - ++current; - } - return out; - } - struct md5_ { static constexpr const boost::string_ref name = ceref(u8"MD5"); @@ -156,7 +138,7 @@ namespace std::array<std::uint8_t, 16> digest{{}}; md5::MD5Final(digest.data(), std::addressof(ctx)); - return to_hex(digest); + return epee::to_hex::array(digest); } }; constexpr const boost::string_ref md5_::name; |