aboutsummaryrefslogtreecommitdiff
path: root/src/common/Utilities/Util.h
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2020-07-26 05:20:41 +0200
committerTreeston <treeston.mmoc@gmail.com>2020-07-26 05:20:41 +0200
commit4f570e5d08d0338ac16aace81865c04b0605b0a5 (patch)
treebe2b799e03447692d255c5293e4f7327c777978a /src/common/Utilities/Util.h
parent5e36bf7c67e077bd1664eee59d5758fbae7666cd (diff)
Core/Authserver: Auth cleanup phase 1b, the "I didn't hit Stage All" commit. Sorry. (5e36bf7 follow-up)
Diffstat (limited to 'src/common/Utilities/Util.h')
-rw-r--r--src/common/Utilities/Util.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/common/Utilities/Util.h b/src/common/Utilities/Util.h
index b22295e95a8..59d7d53bce9 100644
--- a/src/common/Utilities/Util.h
+++ b/src/common/Utilities/Util.h
@@ -21,6 +21,7 @@
#include "Define.h"
#include "Errors.h"
+#include <array>
#include <string>
#include <sstream>
#include <utility>
@@ -308,6 +309,19 @@ TC_COMMON_API std::string ByteArrayToHexStr(uint8 const* bytes, size_t length, b
template <typename Container>
std::string ByteArrayToHexStr(Container const& c, bool reverse = false) { return ByteArrayToHexStr(std::data(c), std::size(c), reverse); }
TC_COMMON_API void HexStrToByteArray(std::string const& str, uint8* out, bool reverse = false);
+template <size_t Size>
+void HexStrToByteArray(std::string const& str, std::array<uint8, Size>& buf, bool reverse = false)
+{
+ ASSERT(str.size() == (2 * Size));
+ HexStrToByteArray(str, buf.data(), reverse);
+}
+template <size_t Size>
+std::array<uint8, Size> HexStrToByteArray(std::string const& str, bool reverse = false)
+{
+ std::array<uint8, Size> arr;
+ HexStrToByteArray(str, arr, reverse);
+ return arr;
+}
TC_COMMON_API bool StringToBool(std::string const& str);