aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/epee/include/string_tools.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/contrib/epee/include/string_tools.h b/contrib/epee/include/string_tools.h
index ce7b2fb87..25639263c 100644
--- a/contrib/epee/include/string_tools.h
+++ b/contrib/epee/include/string_tools.h
@@ -39,6 +39,7 @@
#include <cstdlib>
#include <string>
#include <type_traits>
+#include <regex>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/lexical_cast.hpp>
@@ -349,6 +350,11 @@ POP_WARNINGS
s = *(t_pod_type*)bin_buff.data();
return true;
}
+ //----------------------------------------------------------------------------
+ inline bool validate_hex(uint64_t length, const std::string& str)
+ {
+ return std::regex_match(str, std::regex("'^[0-9abcdefABCDEF]+$'")) && str.size() == length;
+ }
//----------------------------------------------------------------------------
inline std::string get_extension(const std::string& str)
{