diff options
Diffstat (limited to 'src/zencore/iohash.cpp')
| -rw-r--r-- | src/zencore/iohash.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/zencore/iohash.cpp b/src/zencore/iohash.cpp index 8f3f8da26..7200e6e3f 100644 --- a/src/zencore/iohash.cpp +++ b/src/zencore/iohash.cpp @@ -99,6 +99,24 @@ IoHash::FromHexString(std::string_view string) return io; } +bool +IoHash::TryParse(std::string_view Str, IoHash& Hash) +{ + using namespace std::literals; + + if (Str.size() == IoHash::StringLength) + { + return ParseHexBytes(Str.data(), Str.size(), Hash.Hash); + } + + if (Str.starts_with("0x"sv)) + { + return TryParse(Str.substr(2), Hash); + } + + return false; +} + const char* IoHash::ToHexString(char* outString /* 40 characters + NUL terminator */) const { |